In perl's before 5.8 overiding the die handler is supposed to be dangerous, (see the Camel) CGI scripts do it to allow errors to the browser. You can achieve the same effect by wrapping die. sub mydie{#do stuff; die $_[0];}
my $caller =$ENV{CALLER_ID}; How do you know this environment variable is set at this point in your script?
$filename ...should perhaps be a $CONSTANT at the top of your file