#!/usr/bin/perl
use CGI qw/:standard :html3 -no_debug/;

print header;
print start_html('Elliot Phone Lister'),
    "Below should be the phone list tabularized.",p,p;

open(MYFILE, "~/Elliot.txt");
# Format of file is the following:
# Extension <tab> First Name <space> Last Name <tab> Dept. (<tab> Title)
#                                                optional ----^^^^

$n = 0;
while (<MYFILE> != "====") {
    $temp = $_;
    $array[$n] = split(/\t /,$temp);
    $n++;
}

@headings = ('Extention','First','Last','Dept','Title');
@rows = th(\@headings);
foreach $x (0..$n) {
    push(@rows,td([ $array[$x][1] , $array[$x][2] , $array[$x][3] ,
		   $array[$x][4] ]));
}
print table({-border=>undef,-width=>'25%'},caption(b('Elliot Ave')),Tr(\@rows));
print end_html;
