#!/usr/bin/perl
print "Content-type: text/html\n\n";
$myfile = "friends.txt";
$newfriend = $ENV{'QUERY_INFO'};
open(MYFILE, "$myfile") || die;
while() {
if (m/^$newfriend$/) {
print "You are already on the list!\n";
exit;
}
}
close(MYFILE);
push(@friends, $newfriend);
open(MYFILE, ">$myfile") || die;
print MYFILE @friends;
close(MYFILE);
print "You are now in my list, $newfriend!\n"
exit;