logo © 1996 Phil Waclawski
Felitaur Site
Offerings
About Me
Crafts
Services
ftp files
Help Files
What's New?
Home Page
Other Links
Anatomy &
Physiology
Arthropods
Biology
Computers
Ferrets
Fun Links
Internet
Linux
S.C.A.
Win 95/NT
Comments or
Suggestions
webmaster@ felitaur.com
   
[Webscripting Homepage] | [Javascript Homepage] | [Perl/CGI HomePage]
Getting Started with PERL
on Unix
As you will eventually want to use perl to write CGI (common gateway interface programs) you will want to write your perl programs in the right directory. So, assuming your home web directory is www:
  1. cd www
  2. mkdir cgi-bin
    You only have to do this once
  3. cd cgi-bin
  4. pico programname.pl
    This starts a text editor. Use your own filename instead of "programname"
    NOTE:For many web servers, the ending must be .cgi for it to run as a CGI program
  5. for the first line (very top of the file) type:
    #!/usr/bin/perl  -w
  6. Remember, if you are not sure where perl is located, type which perl at the command prompt BEFORE you start pico
  7. You may also want to check out the Cheat Sheet for mcunix students and using UNIX and pico to create web pages help.
  8. Type up your program, and then hit ctrl o [enter] to save it, or hit ctrl x type y as you want to save changes, and then [enter] unless you want to change the name.
  9. Now, you only have to do this once per file, but pico just edits files, it does not change the permissions, and you need to tell the OS that this IS a program, so
  10. type chmod a+x filename.pl where "filename" is the name of YOUR file.
  11. To TEST the program without using a form, you must type the following

    ./filename.pl at the command prompt and hit enter.

  12. Now Debug to your heart's content.

Handy commands, bits to know

  • after logging in, you need to
  • cd www if you want to work on your web pages
  • If you want to work on your perl/cgi scripts you also need to
  • cd cgi-bin
  • pico filename.pl will create a new file of that name, or edit an existing file, IF you are in that directory
  • ls stands for "list stuff" or the contents of a directory
  • pwd or "present working directory" will show you which directory you are in
  • *****SOME QUICK HELPFUL TIPS AND SHORTCUTS*****
    1. Filename completion: type the command, then the first few letters of the file (assuming you are in the right directory) then hit tab. Example:
      You are in www/cgi-bin
      You type: pico ha and hit tab and you see your file pico hash.pl show up ;)
    2. Use the Up arrow key to go through and redo commands so you don't have to keep typing pico filename.pl and then ./filename.pl