perl-tutorial.pdf

(128 KB) Pobierz
Perl Tutorial
based on a tutorial by Nano Gough
http://www.computing.dcu.ie/~ngough/perl/tutorial.ppt
Why Perl?
Perl is
Pathologically Eclectic Rubbish Lister
the duct tape of the internet
the Swiss-army chain saw of UNIX
good at
text processing
rapid development
flexibility
operating system stuff
in particular UNIX/LINUX
bad at
numeric processing
debugging
efficiency
code re-use
CPAN:large repository of re-usable modules
The Three Virtues of a Good Programmer
(not necessarily of a good Student)
LAZINESS:
The quality that makes you go to great effort to
reduce overall energy expenditure.
makes you want to re-use other people's code
IMPATIENCE:
The anger you feel when the computer is being lazy.
makes you get things done quickly (rapid prototyping)
and efficiently (optimize code)
HUBRIS:
Excessive pride.
makes you want to show off (code sharing) and write
(and maintain) programs that other people won't want
to say bad things about.
Running Perl
#!/usr/local/bin/perl
(tells the file to run through perl)
Use .pl extension
Perl
programName
(to run the program)
Perl -d
programName
(to run using debugger)
Perl – w
programName
(to run with warnings)
Printing
#The hash symbol (#) is use to comment lines of code
; Every statement in perl ends with a semi-colon (;)
Print “Hello World. I love perl.”;
#prints:
Hello World. I love perl.
Print “Hello World\nI love perl\n”;
#prints:
Hello World.
I love perl.
Zgłoś jeśli naruszono regulamin