my @referers = ('$ips'); ... if ($#ARGV < 0) { $ENV{'REQUEST_METHOD'} =~ tr/[a-z]/[A-Z]/; if ($ENV{'REQUEST_METHOD'} eq 'POST') { if(&check_url) { #get data from the web via Cgi.pm } } else { #if it didnt come with data then it needs a form to get it &form; } } .... sub check_url { if ($ENV{'HTTP_REFERER'}) { my $referer; foreach $referer (@referers) { if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) { return 0; } else #the else { #spoken of return 1; # above } #consists of these 4 lines } } html_start("ERROR!"); #the two lines i want to run report_error("ERROR","Source check failed"); #if invalid referer }