FIT3084 revision: PERL and CGI

So, from my notes I took during the PERL lecture:

Exam: need to read in file, process, print to web doc (CGI)

This is what we had to do for the tutorial exercise.

The first and most important thing to remember is the SHEBANG line (so named for the # and !, sharp and bang) with the path to where perl lives.
#! /usr/bin/perl should be fine for the exam.

There are a couple of different ways to read in a file, I like:

open (FILE, 'data.txt');

Then we have to process it.

while () {
}

If we have more than two options in an if… else bracket, we have to use elsif (note the lack of the second e).

if ($var = 1) {
$found = "one";
}
elsif ($var = 2) {
$found = "two";
}
else {
$found = "not one or two";
}
}

Well, there is more, but that’s enough for this blog post.

June 28, 2010 | |

COMMENTS

 

Comments RSS

Leave a Reply