in reply to IP and mail header

Sounds like you want get the ip address of the browser that is invoking the cgi script ?

This doesn't really have much to do with perl, but I believe that most web servers put the remote browser's hostname and ip address in the REMOTE_HOST and REMOTE_ADDR environment variables:

my $rhost = $ENV{"REMOTE_HOST"} || "unknown"; my $raddr = $ENV{"REMOTE_ADDR"} || "unknown"; # use mailer-friendly "x headers" print MAIL "X-REMOTE_HOST: $rhost\n"; print MAIL "X-REMOTE_ADDR: $raddr\n";