##
$file = "some_file.txt";
open(FILE,"$file") or &Error($!);
####
sub Error {
$error = shift or $error = "unknown";
print "Sorry, but there was an error. Could not open $file";
print "Error: $error";
&End;
}
####
close FILE or die "Could not close $file";