You can export a symbol from BEGIN by the old use vars qw($foo); trick:
#!/usr/bin/perl -w
BEGIN {
use vars qw($foo);
$foo = 'bar';
}
use strict;
print "$foo\n";
Does that help? Are you just trying to suppress the "BEGIN failed" message that pops up if you put the die in the BEGIN block? The use vars will help with that:
BEGIN {
use vars qw($err);
$err = $ENV{SM} ? 0 : 1;
push @INC, "$ENV{SM}/../bin" unless $err;
}
die "Environment variable SM not set!\n" if $err;
require 'error.pm';
Philosophy can be made out of anything. Or less -- Jerry A. Fodor