Felitaur Site 
  Offerings
  
 | 
   
 | 
  
   
   
[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: 
- cd www
 
- mkdir cgi-bin
  You only have to do this once 
- cd cgi-bin
 
- 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 
-  for the first line (very top of the file) type:
 #!/usr/bin/perl  -w 
- Remember, if you are not sure where perl is located, type which 
perl at the command prompt BEFORE you start pico
 - You may also want to check out the Cheat Sheet for mcunix students 
and using UNIX and pico to 
create web pages help.
 
- 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.
 
- 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
 
- type chmod a+x filename.pl where "filename" is the name of YOUR 
file.
 
- To TEST the program without using a form, you must type the following
./filename.pl at the command prompt and hit 
enter.   
- 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*****
 
	
	- 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 ;) 
	- 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
 
	 
 
   |    
   
    
 |