in reply to how to use this -- HTTP_REFERER

Your code is fine, the condition can be easily written as...
$referer = $ENV{'HTTP_REFERER'}; my @valid_referers = ( 'http://www.yoursite.com/cgi-bin/a.cgi', 'http://www.yoursite.com/cgi-bin/b.cgi' ); print $query->redirect('/cgi-bin/errorpage.cgi') unless ( grep $_ eq $referer, @valid_referers );
...which basically goes through the list of valid referers and checks if the one you just got is in it.

Hope this helps

"Argument is futile - you will be ignorralated!"