Subject: | Don't prefix package in the module is loaded from main |
Hi,
$ TEST=42 booking-perl -wle 'use Constant::FromGlobal TEST => { env => 1, default =>
11 }; print TEST'
11
$ MAIN_TEST=42 booking-perl -wle 'use Constant::FromGlobal TEST => { env => 1, default
=> 11 }; print TEST'
42
Prefixing package seems awkward/unnatural to me
if it's called from main (lets say inside a .pl file)
So, instead of:
sub var_name {
my ( $class, %args ) = @_;
join "::", @args{qw(package name)};
}
How about this?:
sub var_name {
my ( $class, %args ) = @_;
my($pkg, $name) = @args{qw(package name)};
join "::", ( $pkg eq 'main' ? () : $pkg ), $name;
}