I have a module that should do some validation in a BEGIN block. This prevents the user from viewing the useless message along the line (during the compilation phase visible in the second BEGIN here).
The problem is that if I die in BEGIN, then the message that I throw is buried
BEGIN failed--compilation aborted at. However, I prefer dieto exit 1, since then it will be a trap. Should I just use exit 1or is there something I can do to suppress this extra message?
use strict;
use warnings;
BEGIN {
my $message = "Useful message, helping the user prevent Horrible Death";
if ($ENV{AUTOMATED_TESTING}) {
print $message;
exit 0;
} else {
die $message;
}
}
BEGIN {
die "Horrible Death with useless message.";
}
source
share