Introduction to Perl

Article Index

  1. Perl Basics
  2. Comments and Statements
  3. Your First Perl Program

Perl Basics

First of all, I would like to explain the very first line found in every perl program.

Example:

1. #!/usr/bin/perl

This line tells the server what to do with the file when it is executed. The location to your server's Perl program can vary. Check with your server administrator for the correct path to Perl.

Comments and Statements

Comments can be inserted into a program with the # symbol. Anything from the # to the end of the line is ignored by perl. When stretching comments over several lines, use a # symbol on each line.

Everything else is a Perl statement (or code) which must end with a semicolon. If a statement does not end in a semicolon, perl will encounter run-time errors.

Your First Perl Program

Example:

1.
2.
3.
#!/usr/bin/perl
# A Program to do the obivious
print 'Hello world.'; # Print a message

Lets examine this program a little. Line 1 tells the server what to do with the file. Line 2 is a comment. Line 3 has a print function. Below is the output of this program.

Output:

Hello world.

Published by: Thomas Penwell
Initially published on: June 16, 2011
Article last modified on: Thursday, January 26, 2012.

Home - Web Portfolio - Web site Tools - Database Design Service - Consulting
Web Design Service - Web Hosting Solutions - Service Rates - Rentals/Loaners
Client Login - Feedback Form - Promotions - Partners - Articles - Perl Scripts