Introduction to Perl. Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …. Perl? perl? PERL?. The name of the language is "Perl". Any expansion you may read was made up after the fact. "PERL" is *never* correct.
Introduction to Perl
Practical Extraction and Report Language
Pathologically Eclectic Rubbish Lister
# Type and run thisprint "Hello", " ", "World", "\n";print ("Five plus three: ", 5+3);
# This is a comment.
# The following command reads what you
# type and does nothing with the input
# WHY? Run it with and without the command!
NEXT:store the above as simple1.pl
type to exec
#!/usr/bin/perl –w # only for Unix programs
#This is your first Perl program
# It prints data to the screen and reads information from the keyboard
print "Hello mister user\n"; # Print introduction
print 'What is your name:';
$line = <STDIN>; # Grabs everything up to and including the \n
chomp($line);# removes the \n
print 'Well ',$line, " welcome to Perl \n\n\n";
print 'HIT return to exit!';
#The above line keeps the window open so you can look at the output
When Perl sees an expression that doesn’t make sense, such as a variable that has not been given a value, it tends to just silently pass over the problem and use some default value such as undef.
Perl may make the wrong assumption! So make sure it does what you want it to!
Perl is known to compile all kinds of gobbly gook.
Example: Take the previous program and remove the first ;
Then resave it and double click on the .pl file.
WHAT DO YOU SEE???
Well , What can we do to see its comments.
#Type this in and run it using the dos command line
# Make several errors and see what happens.
print “Enter the value of x: “;
$x=<STDIN>;# Reads line up to and including the \n
chomp($x);# Removes the \n
print “Enter the value of y: “;
# Note the double quotes in the following command!
print “The sum of $x and $y is “, $z,”\n”;
print ‘HIT return to exit!’;