Perl


Perl is an interpreted language written by Larry Wall. The language has a vast number of benefits and is widely deployed.

CREATED 2017-05-19 19:53:42.0

00-29-EE

UPDATED 2017-05-19 19:53:42.0

Quotes


Quotes in Perl work very similar to quotes in the shell. Double quotes get substitution: Now you know the REST of the $story while single quotes say 'leave your hands off of me!'

Also in Perl you can "pick your own quotes". q/This is a firm quote/ is a quote. So is q(Another frim quote) and q[Quotes a bunch] but not q(Bad quote]. Whatever character you use... they have to match.

CREATED 2017-05-25 07:29:09.0

00-29-EF

UPDATED 2017-05-25 07:29:33.0

Here Documents


print <<EOF; This is a test of the Emergency Broadcast System
If this had been an actual emergency
you would have been instructed on where to tune in your area.
EOF
print <<"" x 10
This is a test!

print <<FIRST, <<SECOND;
This is the first section of text,
maybe a couple lines.
FIRST
This is the second section.
of text
maybe
a few more lines.
SECOND

In Perl the here document is similar to the shell with a few extras. The << simbol indicates the terminator of the here doc.


Three points to remember.

  • There is no space between the << and the marker (EOF).
  • Don't forget the trailing semi-colon in the print statement and
  • Don't forget their is no trailing semi-colon in the end of document marker.

Another use is to repeat lines, this snippet repeats This is a test! 10 times:

NOTE: This must be followed by a blank line, two if it is the end of a file.

Here documents can also be nested...

This needs the (<<) operator for each label.

CREATED 2017-05-26 13:50:52.0

00-29-F0

UPDATED 2017-05-26 13:50:58.0

L
I
N
K
S

DBID: db.wam

Page Server: Ithica

©2019 Leistware.com
        Hello anonymous