LINUX CLASSES - PERL PROGRAMMING
Perl - What Basics Should I Know?
Perl is an interpreted language that is very popular in the Unix community because it has
a rich and powerful feature set, but is still easy to use. Perl borrows heavily from other
languages such as C and awk and is especially useful for processing text, generating
reports, and handling Common Gateway Interface (CGI) requests submitted via Web
Perl has been ported to many non-Unix environments, including DOS, OS/2, Macintosh,
VMS, and Windows NT. The fact that a Perl program can run with little or no
modification on many different platforms is another reason for its popularity. In this
section, I'll introduce you to basics of Perl and point you to some resources where you
can learn more.
To create a Perl script, use a text editor to enter Perl commands, save the file with a .pl
extension (such as sample.pl), and then use chmod to mark the file as executable. The
extension is not required, but it's a common Unix convention and will help you identify
your Perl source files without looking inside.
Here's a very simple Perl script:
print "I am here. \n";
The mysterious first line starting with "pound splat slash" is required for all Perl scripts
to run; it tells the system where to find the Perl interpreter. Hopefully, you've already
figured out that this program prints a message followed by the newline character.
Unlike the echo command in Bash scripts, Perl's print command doesn't automatically
send a carriage return and line feed. If you forget the \n sequence, the next print
command will start on the same line. Also note that all Perl statements must end with a
Previous Lesson: Shell Script Debugging
Next Lesson: Perl Variables
[ RETURN TO INDEX ]
Comments - most recent first
(Please feel free to answer questions posted by others!)
(19 Dec 2012, 13:30
CORRECTION: The URL should be as follows:
(19 Dec 2012, 12:25
See this page in Serbo-Croation language:
(19 Mar 2012, 05:30
Thanks for this brief, but very helpfull perl basics course. Great job.
(28 Feb 2012, 10:14
thank u for giving information about perl i learned some basics about the
pearl on ur site
(06 Dec 2011, 08:00
well in gentoo to install perl you type emerge perl, in other systems use
yum perl or yast perl.
(08 Jul 2011, 20:17
Sorry for silly question, but how to upgrade/install perl?
(28 Apr 2011, 12:41
thank u for giving information about perl i learned some basics
about the pearl on ur site
it's good for basic learners
(18 Apr 2011, 21:20
I been learning Perl for quite some time.I'm still
looking for a compiler(preferably online).
(03 Apr 2011, 14:17
Doc, it's about time I found this site! Thanks to your work, the stuff in
all those O'Reilly books is finally starting to make sense. Appreciate your
expert guidance through the Perly maze.
my $Nooby = $0;
(21 Mar 2011, 13:13
A really helpful site for someone not looking for tons of programming
I'm an applied mathematics student , and this site helped me regain hang of
the linux i had studied years ago, in couple of hours.
it would be great if you could provide an introduction to Python as well.
(20 Jan 2011, 03:44
hi am eee student in jntu university i need some pdf linux books if u can
(28 Nov 2010, 15:00
(08 Nov 2010, 04:12
hi am cs student in kabul university i need some pdf linux books if u can
(29 Sep 2010, 13:01
Very helpful, great for just getting started. Thanks.
(15 Aug 2010, 15:03
hi this shirish shukla from india
am just completd RHCE exam with 100%
I need your help for understanding
perl scripting from base
would be great if you coluld sent me any pdf or any files hat started from
base of learning..
(04 Aug 2010, 15:10
exactly what I was looking for, thanks.
(06 Apr 2010, 07:36
You could enter:
Or make sure it's executable with the command:
chmod a+rx example.pl
Then you can run it just by typing:
(03 Apr 2010, 11:37
Could you notify How to run script after create it as $./example.pl
(19 Mar 2010, 04:11
very good disciption about all the things...nice one...thnku..
I welcome your comments. However... I am puzzled by many people
who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn
all you can, ask questions if you like. But don't ask me to send what you already have. :-)
NO SPAM! If you post garbage, it will be deleted, and you will be banned.