Getting Started
Introduction
Perl IDEs
History
Advice
Tools
Mini-Tutorial
Tutorial
Code Snippets

Resources
Top Sites
More Tutorials
Books
Magazines
Articles
NewsLetters
Mailing Lists
NewsGroups
Forums
User Groups
Talk Shows
Blogs
Clothing

GBIC >> Perl >> Information Center Tutorials

Perl Information Center Tutorials
These tutorials were written to help you get a quick, but thorough, understanding of Perl - the scope of the language as well as it's specific capabilities.

Beginners Built-In Functions     Advanced CGI Applications

Introduction
As a simple introduction to Perl, I've included the following example along with instructions on how to run it on your PC or on a remote web server. The tutorials listed above go into far more detail.

A Simple Program
Just to get you started, here's a quick look at a traditional "Hello World" program.

   #!/usr/bin/perl        # this line required in Unix, optional on PCs
   $name="Hello World";   # assigns a string value to the variable $name
   print $name;           # prints the variable $name to the screen

Executing a Perl Script Locally
To run the script on a local PC just save it to a file, such as "myscript.pl", then type in:

    perl myscript.pl   # explicitly uses the compiler "perl.exe"
       or
    myscript.pl        # Perl installation set PATH to point to perl.exe

Any filename can be used but .pl and .cgi are commonly used extensions.

Executing a Perl Script Remotely
A Perl script can be run on a local PC, just like any other program, but Perl is most often used on web servers - placed on the server for users to execute via web page interfaces. The two basic ways to use a web page to execute a Perl script on a server are hyperlinks and forms.

In both cases, once the script is executed on the server, the output of the script (typically a web page generated on the fly) is returned to the calling browser.

  • Hyperlink
    A standard web page hyperlink can be used to run a Perl script as in this example.

        <a href="myscript.pl">Execute a Script</a>
    

  • HTML Form
    A form can also direct a web server to execute a Perl script, with the added benefit that the values of all elements in the form are made available to the script by the web server.

        <form action=myscript.pl >
          ... form elements go here
        </form>
    

If you have any suggestions for additions to these tutorials, please let me know.