I've got a script that throws an exception via die
. When I catch the exception I want to output the message without the location information attached.
This script:
#! /usr/bin/perl -w
use strict;
eval {
die "My error message";
};
if($@) {
print $@;
}
outputs
My error message at d:\src\test.pl line 7.
I would prefer just to get the output:
My error message
Hopefully people don't focus on why I want to do it but if someone is interested then:
The way my script works, it looks for input and dispatches each piece of input to a handler, if it comes across a piece of input that it can't handle then it throws, so all the exceptions are coming from the same piece of code. Hence the location isn't terribly helpful in this situation.