<s>
The	O
structure	O
of	O
the	O
Perl	B-Language
programming	I-Language
language	I-Language
encompasses	O
both	O
the	O
syntactical	O
rules	O
of	O
the	O
language	O
and	O
the	O
general	O
ways	O
in	O
which	O
programs	O
are	O
organized	O
.	O
</s>
<s>
Perl	B-Language
's	O
design	O
philosophy	O
is	O
expressed	O
in	O
the	O
commonly	O
cited	O
motto	O
"	O
there	B-Architecture
's	I-Architecture
more	I-Architecture
than	I-Architecture
one	I-Architecture
way	I-Architecture
to	I-Architecture
do	I-Architecture
it	I-Architecture
"	O
.	O
</s>
<s>
As	O
a	O
multi-paradigm	O
,	O
dynamically	O
typed	O
language	O
,	O
Perl	B-Language
allows	O
a	O
great	O
degree	O
of	O
flexibility	O
in	O
program	O
design	O
.	O
</s>
<s>
Perl	B-Language
also	O
encourages	O
modularization	O
;	O
this	O
has	O
been	O
attributed	O
to	O
the	O
component-based	O
design	O
structure	O
of	O
its	O
Unix	O
roots	O
,	O
and	O
is	O
responsible	O
for	O
the	O
size	O
of	O
the	O
CPAN	B-Language
archive	O
,	O
a	O
community-maintained	O
repository	O
of	O
more	O
than	O
100,000	O
modules	O
.	O
</s>
<s>
In	O
Perl	B-Language
,	O
the	O
minimal	O
Hello	O
World	O
program	O
may	O
be	O
written	O
as	O
follows	O
:	O
</s>
<s>
This	O
prints	B-General_Concept
the	O
string	O
Hello	O
,	O
World	O
!	O
</s>
<s>
and	O
a	O
newline	O
,	O
symbolically	O
expressed	O
by	O
an	O
n	O
character	O
whose	O
interpretation	O
is	O
altered	O
by	O
the	O
preceding	O
escape	B-Algorithm
character	I-Algorithm
(	O
a	O
backslash	O
)	O
.	O
</s>
<s>
An	O
entire	O
Perl	B-Language
program	O
may	O
also	O
be	O
specified	O
as	O
a	O
command-line	O
parameter	O
to	O
Perl	B-Language
,	O
so	O
the	O
same	O
program	O
can	O
also	O
be	O
executed	O
from	O
the	O
command	O
line	O
(	O
example	O
shown	O
for	O
Unix	O
)	O
:	O
</s>
<s>
The	O
hash	B-Application
mark	O
character	O
introduces	O
a	O
comment	O
in	O
Perl	B-Language
,	O
which	O
runs	O
up	O
to	O
the	O
end	O
of	O
the	O
line	O
of	O
code	O
and	O
is	O
ignored	O
by	O
the	O
compiler	O
(	O
except	O
on	O
Windows	O
)	O
.	O
</s>
<s>
The	O
comment	O
used	O
here	O
is	O
of	O
a	O
special	O
kind	O
:	O
it	O
’s	O
called	O
the	O
shebang	B-Operating_System
line	I-Operating_System
.	O
</s>
<s>
This	O
tells	O
Unix-like	O
operating	O
systems	O
to	O
find	O
the	O
Perl	B-Language
interpreter	I-Language
,	O
making	O
it	O
possible	O
to	O
invoke	O
the	O
program	O
without	O
explicitly	O
mentioning	O
perl	B-Language
.	O
</s>
<s>
(	O
Note	O
that	O
,	O
on	O
Microsoft	B-Application
Windows	I-Application
systems	O
,	O
Perl	B-Language
programs	O
are	O
typically	O
invoked	O
by	O
associating	O
the	O
.pl	O
extension	O
with	O
the	O
Perl	B-Language
interpreter	I-Language
.	O
</s>
<s>
In	O
order	O
to	O
deal	O
with	O
such	O
circumstances	O
,	O
perl	B-Language
detects	O
the	O
shebang	B-Operating_System
line	I-Operating_System
and	O
parses	O
it	O
for	O
switches	O
.	O
)	O
</s>
<s>
The	O
second	O
line	O
in	O
the	O
canonical	O
form	O
includes	O
a	O
semicolon	O
,	O
which	O
is	O
used	O
to	O
separate	O
statements	O
in	O
Perl	B-Language
.	O
</s>
<s>
Version	O
5.10	O
of	O
Perl	B-Language
introduces	O
a	O
say	O
function	O
that	O
implicitly	O
appends	O
a	O
newline	O
character	O
to	O
its	O
output	O
,	O
making	O
the	O
minimal	O
"	O
Hello	O
World	O
"	O
program	O
even	O
shorter	O
:	O
</s>
<s>
Perl	B-Language
has	O
a	O
number	O
of	O
fundamental	O
data	O
types	O
.	O
</s>
<s>
The	O
most	O
commonly	O
used	O
and	O
discussed	O
are	O
scalars	O
,	O
arrays	O
,	O
hashes	B-Algorithm
,	O
filehandles	B-Application
,	O
and	O
subroutines	O
:	O
</s>
<s>
Type	O
Sigil	O
Example	O
DescriptionScalar$$fooA	O
single	O
value	O
;	O
it	O
may	O
be	O
a	O
number	O
,	O
a	O
string	O
,	O
a	O
filehandle	B-Application
,	O
or	O
a	O
reference.Array	O
@	O
@fooAn	O
ordered	O
collection	O
of	O
scalars.Hash	O
%%fooA	O
map	O
from	O
strings	O
to	O
scalars	O
;	O
the	O
strings	O
are	O
called	O
keys	O
,	O
and	O
the	O
scalars	O
are	O
called	O
values	O
.	O
</s>
<s>
Also	O
known	O
as	O
an	O
associative	O
array.Filehandlenone	O
$foo	O
or	O
FOOAn	O
opaque	O
representation	O
of	O
an	O
open	O
file	O
or	O
other	O
target	O
for	O
reading	O
,	O
writing	O
,	O
or	O
both.Subroutine	O
&&fooA	O
piece	O
of	O
code	O
that	O
may	O
be	O
passed	O
arguments	O
,	O
be	O
executed	O
,	O
and	O
return	O
data.Typeglob**fooThe	O
symbol	B-Application
table	I-Application
entry	O
for	O
all	O
types	O
with	O
the	O
name	O
'	O
foo	O
 '	O
.	O
</s>
<s>
Perl	B-Language
will	O
convert	O
numbers	O
into	O
strings	O
and	O
vice	O
versa	O
depending	O
on	O
the	O
context	O
in	O
which	O
they	O
are	O
used	O
.	O
</s>
<s>
This	O
code	O
prints	B-General_Concept
the	O
number	O
'	O
5	O
 '	O
.	O
</s>
<s>
Note	O
that	O
in	O
Perl	B-Language
,	O
+	O
is	O
always	O
the	O
numeric	O
addition	O
operator	O
.	O
</s>
<s>
Functions	O
are	O
provided	O
for	O
the	O
rounding	B-Algorithm
of	O
fractional	O
values	O
to	O
integer	O
values	O
:	O
int	O
chops	O
off	O
the	O
fractional	O
part	O
,	O
rounding	B-Algorithm
towards	O
zero	O
;	O
POSIX::ceil	O
and	O
POSIX::floor	O
round	O
always	O
up	O
and	O
always	O
down	O
,	O
respectively	O
.	O
</s>
<s>
The	O
number-to-string	O
conversion	O
of	O
printf	O
"	O
%f	O
"	O
or	O
sprintf	O
"	O
%f	O
"	O
round	O
out	O
even	O
,	O
use	O
bankers	O
 '	O
rounding	B-Algorithm
.	O
</s>
<s>
Perl	B-Language
also	O
has	O
a	O
boolean	O
context	O
that	O
it	O
uses	O
in	O
evaluating	O
conditional	O
statements	O
.	O
</s>
<s>
The	O
following	O
values	O
all	O
evaluate	O
as	O
false	O
in	O
Perl	B-Language
:	O
</s>
<s>
All	O
non-numeric	O
strings	O
also	O
have	O
this	O
property	O
,	O
but	O
this	O
particular	O
string	O
is	O
truncated	O
by	O
Perl	B-Language
without	O
a	O
numeric	O
warning	O
.	O
</s>
<s>
The	O
empty	O
hash	B-Application
 {  } 	O
is	O
also	O
true	O
;	O
in	O
this	O
context	O
 {  } 	O
is	O
not	O
an	O
empty	O
block	O
,	O
because	O
perl	B-Language
-e	O
'	O
print	O
ref	O
 {  } 	O
 '	O
returns	O
HASH	B-Application
.	O
</s>
<s>
The	O
split	O
function	O
returns	O
a	O
list	O
of	O
strings	O
,	O
which	O
are	O
split	O
from	O
a	O
string	O
expression	O
using	O
a	O
delimiter	O
string	O
or	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
Perl	B-Language
programmers	O
may	O
initialize	O
a	O
hash	B-Application
(	O
or	O
associative	B-Application
array	I-Application
)	O
from	O
a	O
list	O
of	O
key/value	O
pairs	O
.	O
</s>
<s>
If	O
the	O
keys	O
are	O
separated	O
from	O
the	O
values	O
with	O
the	O
=>	O
operator	O
(	O
sometimes	O
called	O
a	O
fat	B-Language
comma	I-Language
)	O
,	O
rather	O
than	O
a	O
comma	O
,	O
they	O
may	O
be	O
unquoted	O
(	O
barewords	O
)	O
.	O
</s>
<s>
Individual	O
values	O
in	O
a	O
hash	B-Application
are	O
accessed	O
by	O
providing	O
the	O
corresponding	O
key	O
,	O
in	O
curly	O
braces	O
.	O
</s>
<s>
A	O
hash	B-Application
can	O
also	O
be	O
initialized	O
by	O
setting	O
its	O
values	O
individually	O
:	O
</s>
<s>
Filehandles	B-Application
provide	O
read	O
and	O
write	O
access	O
to	O
resources	O
.	O
</s>
<s>
These	O
are	O
most	O
often	O
files	O
on	O
disk	O
,	O
but	O
can	O
also	O
be	O
a	O
device	O
,	O
a	O
pipe	B-Operating_System
,	O
or	O
even	O
a	O
scalar	O
value	O
.	O
</s>
<s>
Originally	O
,	O
filehandles	B-Application
could	O
only	O
be	O
created	O
with	O
package	O
variables	O
,	O
using	O
the	O
ALL_CAPS	O
convention	O
to	O
distinguish	O
it	O
from	O
other	O
variables	O
.	O
</s>
<s>
Perl	B-Language
5.6	O
and	O
newer	O
also	O
accept	O
a	O
scalar	O
variable	O
,	O
which	O
will	O
be	O
set	O
(	O
autovivified	B-Language
)	O
to	O
a	O
reference	O
to	O
an	O
anonymous	O
filehandle	B-Application
,	O
in	O
place	O
of	O
a	O
named	O
filehandle	B-Application
.	O
</s>
<s>
A	O
typeglob	O
value	O
is	O
a	O
symbol	B-Application
table	I-Application
entry	O
.	O
</s>
<s>
The	O
main	O
use	O
of	O
typeglobs	O
is	O
creating	O
symbol	B-Application
table	I-Application
aliases	O
.	O
</s>
<s>
There	O
are	O
a	O
few	O
functions	O
that	O
operate	O
on	O
entire	O
hashes	B-Algorithm
.	O
</s>
<s>
The	O
keys	O
function	O
takes	O
a	O
hash	B-Application
and	O
returns	O
the	O
list	O
of	O
its	O
keys	O
.	O
</s>
<s>
Similarly	O
,	O
the	O
values	O
function	O
returns	O
a	O
hash	B-Application
's	O
values	O
.	O
</s>
<s>
Perl	B-Language
has	O
several	O
kinds	O
of	O
control	O
structures	O
.	O
</s>
<s>
It	O
has	O
block-oriented	O
control	O
structures	O
,	O
similar	O
to	O
those	O
in	O
the	O
C	O
,	O
JavaScript	B-Language
,	O
and	O
Java	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Perl	B-Language
also	O
has	O
two	O
implicit	O
looping	O
constructs	O
,	O
each	O
of	O
which	O
has	O
two	O
forms	O
:	O
</s>
<s>
These	O
constructs	O
enable	O
a	O
simple	O
functional	B-Language
programming	I-Language
style	O
.	O
</s>
<s>
Up	O
until	O
the	O
5.10.0	O
release	O
,	O
there	O
was	O
no	O
switch	O
statement	O
in	O
Perl	B-Language
5	O
.	O
</s>
<s>
For	O
those	O
not	O
using	O
Perl	B-Language
5.10	O
,	O
the	O
Perl	B-Language
documentation	O
describes	O
a	O
half-dozen	O
ways	O
to	O
achieve	O
the	O
same	O
effect	O
by	O
using	O
other	O
control	O
structures	O
.	O
</s>
<s>
There	O
is	O
also	O
a	O
Switch	O
module	O
,	O
which	O
provides	O
functionality	O
modeled	O
on	O
that	O
of	O
sister	O
language	O
Raku	B-Application
.	O
</s>
<s>
Perl	B-Language
includes	O
a	O
goto	O
label	O
statement	O
,	O
but	O
it	O
is	O
rarely	O
used	O
.	O
</s>
<s>
Situations	O
where	O
a	O
goto	O
is	O
called	O
for	O
in	O
other	O
languages	O
do	O
n't	O
occur	O
as	O
often	O
in	O
Perl	B-Language
,	O
because	O
of	O
its	O
breadth	O
of	O
flow	O
control	O
options	O
.	O
</s>
<s>
There	O
is	O
also	O
a	O
goto	O
&	O
sub	O
statement	O
that	O
performs	O
a	O
tail	B-Language
call	I-Language
.	O
</s>
<s>
This	O
is	O
used	O
in	O
situations	O
where	O
a	O
caller	O
can	O
perform	O
more-efficient	O
stack	B-General_Concept
management	O
than	O
Perl	B-Language
itself	O
(	O
typically	O
because	O
no	O
change	O
to	O
the	O
current	O
stack	B-General_Concept
is	O
required	O
)	O
,	O
and	O
in	O
deep	O
recursion	O
,	O
tail	O
calling	O
can	O
have	O
substantial	O
positive	O
impact	O
on	O
performance	O
,	O
because	O
it	O
avoids	O
the	O
overhead	O
of	O
scope/stack	O
management	O
on	O
return	O
.	O
</s>
<s>
Arguments	O
may	O
be	O
scalars	O
,	O
lists	O
,	O
or	O
hashes	B-Algorithm
.	O
</s>
<s>
Arrays	O
are	O
expanded	O
to	O
their	O
elements	O
;	O
hashes	B-Algorithm
are	O
expanded	O
to	O
a	O
list	O
of	O
key/value	O
pairs	O
;	O
and	O
the	O
whole	O
lot	O
is	O
passed	O
into	O
the	O
subroutine	O
as	O
one	O
flat	O
list	O
of	O
scalars	O
.	O
</s>
<s>
This	O
is	O
especially	O
common	O
when	O
the	O
subroutine	O
takes	O
only	O
one	O
argument	O
or	O
for	O
handling	O
the	O
$self	O
argument	O
in	O
object-oriented	B-Language
modules	O
.	O
</s>
<s>
Subroutines	O
may	O
assign	O
@_	O
to	O
a	O
hash	B-Application
to	O
simulate	O
named	O
arguments	O
;	O
this	O
is	O
recommended	O
in	O
Perl	B-Language
Best	O
Practices	O
for	O
subroutines	O
that	O
are	O
likely	O
to	O
ever	O
have	O
more	O
than	O
three	O
parameters	O
.	O
</s>
<s>
Arrays	O
and	O
hashes	B-Algorithm
in	O
the	O
return	O
value	O
are	O
expanded	O
to	O
lists	O
of	O
scalars	O
,	O
just	O
as	O
they	O
are	O
for	O
arguments	O
.	O
</s>
<s>
The	O
Perl	B-Language
language	I-Language
includes	O
a	O
specialized	O
syntax	O
for	O
writing	O
regular	B-Language
expressions	I-Language
(	O
RE	O
,	O
or	O
regexes	B-Language
)	O
,	O
and	O
the	O
interpreter	O
contains	O
an	O
engine	O
for	O
matching	O
strings	O
to	O
regular	B-Language
expressions	I-Language
.	O
</s>
<s>
The	O
regular-expression	O
engine	O
uses	O
a	O
backtracking	B-Algorithm
algorithm	I-Algorithm
,	O
extending	O
its	O
capabilities	O
from	O
simple	O
pattern	O
matching	O
to	O
string	O
capture	O
and	O
substitution	O
.	O
</s>
<s>
The	O
regular-expression	O
engine	O
is	O
derived	O
from	O
regex	B-Language
written	O
by	O
Henry	O
Spencer	O
.	O
</s>
<s>
The	O
Perl	B-Language
regular-expression	O
syntax	O
was	O
originally	O
taken	O
from	O
Unix	O
Version	O
8	O
regular	B-Language
expressions	I-Language
.	O
</s>
<s>
However	O
,	O
it	O
diverged	O
before	O
the	O
first	O
release	O
of	O
Perl	B-Language
and	O
has	O
since	O
grown	O
to	O
include	O
far	O
more	O
features	O
.	O
</s>
<s>
Many	O
other	O
languages	O
and	O
applications	O
are	O
now	O
adopting	O
Perl	B-Language
Compatible	I-Language
Regular	I-Language
Expressions	I-Language
over	O
POSIX	O
regular	B-Language
expressions	I-Language
,	O
such	O
as	O
PHP	B-Application
,	O
Ruby	B-Language
,	O
Java	B-Language
,	O
Microsoft	B-Application
's	I-Application
.NET	I-Application
Framework	I-Application
,	O
and	O
the	O
Apache	B-Application
HTTP	I-Application
server	I-Application
.	O
</s>
<s>
The	O
first	O
regular-expression	O
dialects	O
were	O
only	O
slightly	O
more	O
expressive	O
than	O
globs	B-Language
,	O
and	O
the	O
syntax	O
was	O
designed	O
so	O
that	O
an	O
expression	O
would	O
resemble	O
the	O
text	O
that	O
it	O
matches	O
.	O
</s>
<s>
Over	O
time	O
,	O
the	O
expressiveness	O
of	O
regular	B-Language
expressions	I-Language
grew	O
tremendously	O
,	O
but	O
the	O
syntax	O
design	O
was	O
never	O
revised	O
and	O
continues	O
to	O
rely	O
on	O
punctuation	O
.	O
</s>
<s>
As	O
a	O
result	O
,	O
regular	B-Language
expressions	I-Language
can	O
be	O
cryptic	O
and	O
extremely	O
dense	O
.	O
</s>
<s>
evaluates	O
to	O
true	O
if	O
and	O
only	O
if	O
the	O
string	O
$x	O
matches	O
the	O
regular	B-Language
expression	I-Language
abc	O
.	O
</s>
<s>
Another	O
use	O
of	O
regular	B-Language
expressions	I-Language
is	O
to	O
specify	O
delimiters	O
for	O
the	O
split	O
function	O
:	O
</s>
<s>
The	O
split	O
function	O
creates	O
a	O
list	O
of	O
the	O
parts	O
of	O
the	O
string	O
that	O
are	O
separated	O
by	O
what	O
matches	O
the	O
regular	B-Language
expression	I-Language
.	O
</s>
<s>
Perl	B-Language
regular	B-Language
expressions	I-Language
can	O
take	O
modifiers	O
.	O
</s>
<s>
Because	O
the	O
compact	O
syntax	O
of	O
regular	B-Language
expressions	I-Language
can	O
make	O
them	O
dense	O
and	O
cryptic	O
,	O
the	O
/x	O
modifier	O
was	O
added	O
in	O
Perl	B-Language
to	O
help	O
programmers	O
write	O
more-legible	O
regular	B-Language
expressions	I-Language
.	O
</s>
<s>
It	O
allows	O
programmers	O
to	O
place	O
whitespace	O
and	O
comments	O
inside	O
regular	B-Language
expressions	I-Language
:	O
</s>
<s>
Portions	O
of	O
a	O
regular	B-Language
expression	I-Language
may	O
be	O
enclosed	O
in	O
parentheses	O
;	O
corresponding	O
portions	O
of	O
a	O
matching	O
string	O
are	O
captured	O
.	O
</s>
<s>
Perl	B-Language
regular	B-Language
expressions	I-Language
also	O
allow	O
built-in	O
or	O
user-defined	O
functions	O
to	O
apply	O
to	O
the	O
captured	O
match	O
,	O
by	O
using	O
the	O
/e	O
modifier	O
:	O
</s>
<s>
There	O
are	O
many	O
ways	O
to	O
write	O
object-oriented	B-Language
code	I-Language
in	O
Perl	B-Language
.	O
</s>
<s>
Many	O
modern	O
Perl	B-Language
applications	O
use	O
the	O
Moose	B-Language
object	B-Language
system	I-Language
.	O
</s>
<s>
Moose	B-Language
is	O
built	O
on	O
top	O
of	O
Class::MOP	O
,	O
a	O
meta-object	O
protocol	O
,	O
providing	O
complete	O
introspection	O
for	O
all	O
Moose-using	O
classes	O
.	O
</s>
<s>
Moose	B-Language
classes	O
:	O
</s>
<s>
Moose	B-Language
roles	O
:	O
</s>
<s>
A	O
role	O
is	O
something	O
that	O
a	O
class	O
does	O
,	O
somewhat	O
like	O
mixins	B-Language
or	O
interfaces	O
in	O
other	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Unlike	O
mixins	B-Language
and	O
interfaces	O
,	O
roles	O
can	O
be	O
applied	O
to	O
individual	O
object	O
instances	O
.	O
</s>
<s>
An	O
example	O
of	O
a	O
class	O
written	O
using	O
the	O
MooseX::Declare	O
extension	O
to	O
Moose	B-Language
:	O
</s>
<s>
This	O
is	O
a	O
class	O
named	O
Point3D	O
that	O
extends	O
another	O
class	O
named	O
Point	O
explained	O
in	O
Moose	B-Language
examples	O
.	O
</s>
