MTC logo MTC logo Midlands Technical College
Prospective StudentsEnrolled StudentsFaculty & StaffCommunity Partners
About
Academics
Continuing Education
Distance Learning
Student Forms
Library
Class Schedule
News & Updates
Calendar
Directory
Site Map
Ask MTC
MTC Jobs Bookstore
Home
navigation
 
Search

 

About MTC Academics Continuing Education Distance Learning Student Forms Library Class Schedule News & Updates Calendar Directory Site Map Ask MTC MTC Jobs Bookstore Home


CPT 247


Quick Reference

Exercise

Shellscript1

 

Perl  Practical Examination and Reporting Language

Perl is a programming language that is good fro almost anything.

The author of Perl is Larry Wall. Perl takes advantage of regular expressions for providing pattern matching. It is a complete language ready to handle the complex needs of the programmers.

Assuming that the location of the Perl executable is in the PATH, then one can execute the following:

     perl -e 'print "Hello Columbia, South Carolina!";

The output would look like :

Hello Columbia, South Carolina!

The -e tells Perl to execute the quoted Perl code that follows on the command line.

Larger Perl programs should be saved in a text file and should begin with a pound (#) bang(!) followed by the full pathname of the Perl interpreter.

   #!/usr/local/perl -w

When the Unix shell sees #!, it invokes the Unix command given after #! and passes to that command all the remaining lines of the file to be executed. The  -w option gives warnings about errors and incorrect variable usage. Therefore, the above program can be saved in a Perl program file that looks like this:

#!/usr/local/bin/perl -w

perl -e 'print "Hello Columbia, South Carolina!";

Each line of code must end with some form of termination. The semicolon is the terminate a line. The other is the right curly bracket (}) which is used terminate a block of code.

You can use the type command to locate the correct path of Perl.

    type perl