170 likes | 278 Views
Computer Systems 201. Contacts. Lecturer: Alison Smith Email: alison.smith@curtin.edu.au Office: 204.522 Phone: 9266 7606 The easiest way is to email for an appointment. Introduction to Perl. What is Perl. “Practical Extraction and Report Language” Created by Larry Wall in mid 1980’s
E N D
Contacts Lecturer: Alison Smith Email: alison.smith@curtin.edu.au Office: 204.522 Phone: 9266 7606 The easiest way is to email for an appointment.
What is Perl • “Practical Extraction and Report Language” • Created by Larry Wall in mid 1980’s • Intended to fill gap between high and low level programming.
A Brief History • Larry had a lot of text files • He needed to produce a report • Currently available tools were not powerful enough • Required the speed of shell programming with the power of other high level tools
Perl Is: • Easy to use - once you know how! • Nearly Unlimited • Mostly Fast • Potentially Ugly • High Level Language
What is Perl Good for? • Perl is good for: • Working with text • “quick and dirty” tasks • Web / HTML and CGI Programming • Perl is not good for • Hiding your code
How do I get Perl? • Open Source License • Runs on anything “Unix” • Macs • Windows • Windows Perl • Cygwin • CPAN
“your favorite text editor” • VI • GVIM • Emacs • Windows Text Editor • DO NOT USE A WORD PROCESSOR!
Hello World #!/usr/bin/perl # My first perl program print “Hello World!\n”;
Steps to Running a Program • Create the program with your text editor • Run chmod a+x my_program (only need to perform the chmod once) • ./my_program
What? No compile? • Perl is (usually) an interpreted language • Source is in plain text - no obfuscation • Can compile when necessary
Don’t make life hard! • Steep Learning Curve • Shortcuts • “Write only” perl
Good Form • Perl will interpret your code, good or bad! • Use indents • Use comments # this is a comment • Use white space if necessary
Obfuscated Perl http://perl.plover.com/obfuscated/bestever.pl
Next Week: • Perl Variables • Basic I/O • "If" and "while" statements