#!/usr/bin/perl # use the module we wrote in the last chapter, to import # the form-parser and dienice functions: use mymod qw(parseform dienice); %FORM = &parseform; print "Content-type:text/html\n\n"; print <Whois $FORM{'domain'}

whois $FORM{'domain'}

EndHTML

# untaint it - domain names may only be alphanumeric
if ($FORM{'domain'} =~ /^([\w\-\.]+)$/) {
   $domain = $1;
} else {
   dienice("The domain $FORM{'domain'} is invalid. Domain names must be alphanumeric.");
}

@whois = `whois $domain`;

foreach $i (@whois) {
    print $i;
}

print <


EndHTML2