Here's an example of source code for a Perl program that reads a pipe-delimited data file that contains a list of Titles, Email, City, State, and Zip and prints its output as an HTML list with the email being hyper-linked.
code:
#!/usr/bin/perl
$filename = $form{$employnumber};
$file = $ARGV[0]; open(FILE,$file) or die "Could not read from $filename, program halting. $!";
# print the found results for the current row of data print "<li> $title <a mailto=\"$email\">$email</a> $city, $state, $zip</li>\n"; }
# print the closing tag print "</ul>\n"; close(FILE);
The most important things to know about this Perl script are:
1.The input filename can be provided by the Unix shell script that calls this Perl script instead of declaring the variable at top. (which will be more useful in real life situations)
2.The data file contains at least five pipe-delimited fields. In fact, it can and does have many more than this, but we are only reading the first five fields to retrieve the information we need and discarded the rest. I've named $title, $email, $city, $state and $zip.
3.The program just prints its output to standard output (STDOUT) with print statements.