perls of wisdom n.
Skip this Video
Loading SlideShow in 5 Seconds..
Perls of Wisdom PowerPoint Presentation
Download Presentation
Perls of Wisdom

Loading in 2 Seconds...

play fullscreen
1 / 20

Perls of Wisdom - PowerPoint PPT Presentation

  • Uploaded on

Perls of Wisdom. Introduction. PERL - Practical Extraction and Report Language Larry Wall Author of USENET reader rn and patch Extensive training as linguist. English, Reality, and Perl. Reality is a mess. Since English is also a mess, it maps well onto reality.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Perls of Wisdom' - jaden

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
  • PERL - Practical Extraction and Report Language
  • Larry Wall
  • Author of USENET reader rn and patch
  • Extensive training as linguist
english reality and perl
English, Reality, and Perl
  • Reality is a mess.
  • Since English is also a mess, it maps well onto reality.
  • Perl was designed to be messy (in the nicest possible way.)
  • Modeled after natural languages; constructs can be complex but meaningful without being wordy (unlike this slide, which is very wordy).
perl on simplicity
Perl on Simplicity
  • Perl can be simple, and do many useful things, or it can be complex, and work magic. (Complexity does not necessarily equal code length.)
the creation of perl
The Creation of Perl
  • Originally, made to just be a text processing language.
  • Larry wanted to fill the void between “manipulexity”and “whipupitude”.
  • Perl violates a rule of Unix: a tool should do one thing, and do it well.
perl of wisdom 1
Perl of Wisdom #1
  • There is more than one way to do it.
don t have mad skills
Don’t have mad skills?
  • A little bit of Perl can go a long way. A 3 year old can speak English and be understood, despite having a very limited vocabulary.
  • The same language spoken by a 3 year old is used by philosophers and geniuses to explain extremely complex things.
if all else fails what would george do
If all else fails, What Would George Do?
  • George Would Read The Fine Manual
  • man perl
  • If man pages aren’t your thing, perhaps you should invest in a good book.
  • -w is your friend.
perl of wisdom 2
Perl of Wisdom #2
  • Easy things should be easy, hard things should be possible
  • A camel is ugly, stinky, and spits, but gets you where you're going.
howdy y all
Howdy Y’all

This is your first coding project in Perl.


print “Howdy Y’all”;

* Note this is an exercise in using the Perl interpreter.

perl is type free
Perl Is Type Free

$answer = 42; # integer

$pi = 3.14159265; # a float

$university = “Drexel”; # a string

$interp = “I go to $university”; # string + interpolation

$noninterp = ‘Its too much $$’; # string – interpolation

$output = `pwd`; # output from a shell command

$status = system(“vi $x”); # status of a command

$dog = new Camel “Fido”; # instantiation of an object

arrays in perl
Arrays in Perl

@nounsare = (“people”, “places”, “things”);

Arrays in Perl generally behave the same way they do in C.

$howmanynouns = @nounsare;

  • While

while (condition) {do this in here;


  • For

for ($i = 1; $i < 10; $i++) {



  • Foreach

foreach $element (@elements) {

do this here


  • Allow Perl to interact with real world stuff.
  • Please close your files.

open(SESAME, “filename”) # read from existing

open(SESAME, “>filename”) # create file and write to it

open(SESAME, “>>filename”) # open existing file and append

close(SESAME); # no one likes to see you with

# your files open anyway...

playing with filehandles
Playing With Filehandles

A Simple Example:

All of these are the same thing.

while (<SESAME>) { print $_; } # Don’t panic, I’ll explain the $_

while (<SESAME>) { print; } # Here the $_ is implied

print while <SESAME>;

Output into files:

print SESAME “This goes out to the file.”

interesting functions i ve met
Interesting Functions I’ve Met.
  • print.

Not only used as: print “blah”;

Try: print << bigblock; # This is more of a print until

print this # you hit the label bigblock

and this


  • chomp and chop.

When taking in strings from files, used to remove last character (usually an annoying newline that can mess things up).

chomp is safer, returns # of characters eaten chop returns character eaten

  • split.
cartwheels and backticks
Cartwheels and Backticks
  • Backticks (` `) can be used to execute commands in a shell.

$info = `finger $user` # Returns all output from command as a string

# Note interpolation

your last perl of wisdom
Your Last Perl of Wisdom
  • Perl gives the programmer as much rope as he or she desires.
  • It’s always enough rope to hang yourself with.
the whole
The Whole #!
  • Applied Perl
  • Perls of Wisdom