Perl is an acronym, short for Practical Extraction and Report Language. It was designed by Larry Wall as a tool for writing programs in the UNIX environment.
Using your favorite UNIX editor, create the following file:
|
1 |
#! /usr/local/bin/perl5 |
|
2 |
# file one |
|
3 |
print "This is the output from one!\n"; |
Exit your editor and give the program a name such as one. Back at the UNIX prompt do two things: set the permissions of the file and run it.
Saul6% chmod 755 one
chmod changes the access mode of a file. Only the owner of a file may change its mode. Here the permissions are set by a three digit number: 755 which assigns read-write-execute permission to the owner and read-execute permission to everyone else.
Saul6% one
Runs the file.
Comments:
#! /usr/local/bin/perl5
Perl comments are introduced by the #. The #! is a special comment that signals what interpreter to apply to the file. Here the interpreter is perl5 located in the subdirectories as shown.
# file one
A user-generated comment. The perl interpreter ignores everything from the # to the end of the line.
print "This is the output from one!\n";
Prints out some text demarcated by either single or double quotes. Note the use of the backwards slash to turn the following character into a control character:
\n newline
\t tab
\u Force next character to upper case
\l Force next character to lower case
\U Force following characers to upper case
\L Force following characters
to lower case