#!/usr/bin/perl # list-contacts.cgi - print a listing of all Contact files use CGI qw/:standard :html3 :netscape/; use CGI::Carp qw(fatalsToBrowser carpout); use HTML::Entities (); # $encoded = HTML::Entities::encode($a); # $decoded = HTML::Entities::decode($a); use vars qw { $DEBUG }; $DEBUG = 1; use vars qw{ @REQUIRED @OPTIONAL @HIDDEN @VIEWABLE}; @REQUIRED = qw/ Last_name Taligent_title First_name /; @OPTIONAL = qw/ Enum EmpType NoNumber Phone Fax Email URL Address CCompany CTitle /; @HIDDEN = qw / EmpNum /; use vars qw { $Enum, $enum, $EmpType, $Last_name }; use vars qw {$ContactDir $ContactFile $SequenceNumbers}; $webdir = "/WWW/technofile/Talumni"; $ContactDir = "$webdir/Contacts"; $ContactFile = "$webdir/contactData.htm"; $SequenceNumbers = "$webdir/NextInSequence"; #main { my @contactlist; my $contactfile; my $EmpNum; my $EmpType; my %mod_date; chdir($webdir); print header, start_html(-title=>'Taligent Alumni Contact List', -background=>"", -bgcolor=>"white", ), center(h1("Taligent Alumni Contact List")); print hr, h3("This is an alphabetical list of all the Taligent Alumni that " . "have registered so far; " . "if you are not yet on this list, please " . "fill out the ", a({-href=>'./check-reg.cgi'}, "Registry"), ".\n", p, "You can also return to our ", a({-href=>'http://www.technofile.org/talumni'}, "home page") ), hr, br, br; $pwd = `pwd`; chdir($ContactDir); opendir(DIR, '.') or die "Cannot open $ContactDir: $!"; @contactlist = grep (/[TXC].*\.htm$/, readdir(DIR)); closedir(DIR); foreach my $contactfile (@contactlist) { open(FH, $contactfile) or die "Cannot open $contactfile: $!"; ($EmpNum, $EmpType) = get_empnum_type($contactfile); $mod_date{$EmpNum} = mod_date($contactfile); $record=; #slurp if ($record =~ m{^

(.*),\s(.*)

.*}) { $Last_name = lc($1); $First_name = lc($2); } else { $Last_name = ''; $First_name = ''; } while (defined($contacts{"$Last_name, $First_name"})) { $First_name .= ' '; } $contacts{"$Last_name, $First_name"} = $record; $empnum{"$Last_name, $First_name"} = $EmpNum; $emptype{"$Last_name, $First_name"} = $EmpType; } foreach my $contact (sort keys(%contacts)) { my $emptype = $emptype{$contact}; my $mod_date = $mod_date{$empnum{$contact}}; print "$emptype - data last updated: $mod_date

\n"; print $contacts{$contact}; } chdir($pwd); print end_html; } sub get_empnum_type { my $EmpNum = shift; my $t = ''; my $EmpType = ''; $EmpNum =~ s/^.*([TCX])(.*)\.htm/$2/; $t = $1; $EmpNum = sprintf("%04d", $EmpNum); $EmpNum = $t . $EmpNum; if ($t =~ /[TX]/) { $EmpType = 'Permanent'; } else { $EmpType = 'Contract'; } return ($EmpNum, $EmpType ); } sub mod_date { # # return the modification time my($filename) = @_; my(@mtime, $mod); @mtime = localtime((stat "$filename")[9]); $mod_date = sprintf("%02d-%02d-%s\n", $mtime[4]+1, $mtime[3], $mtime[5]+1900); return($mod_date); } # sub modtime