#!/usr/bin/perl -wT use strict; use CGI qw/:standard/; $ENV{PATH} = "/cgi-bin"; # untaint and return value sub IP_check { my $_info2 = $ENV{'REMOTE_ADDR'}; my $info; if (!$_info2) { $info2 = "No IP address available"; return $info2; }elsif ($_info2 !~ /[\%]+/ && $_info2 =~ /^(\d{1,3}\.{1})(\d{1,3}\.{1})(\d{1,3}\.{1})(\d{1,3})$/) { # my $info2 = "$1$2$3$4"; sorry, forgot to delete the "my" # from the original posting $info2 = "$1$2$3$4"; return $info2; }else { # my info2 = "Bad IP address submitted"; same "my" problem #here $info2 = "Bad IP address submitted"; return $info2; } } if (param()) { # do other stuff here before if statement if (IP_check()) { # do some stuff here before calling sub &mailoff; exit;} } # html form stuff is located here sub mailoff { # open mail handler stuff - omitted for simplicity print MAIL "here is the ip address $info2"; # now the closing stuff }