in reply to examining other package's variable without 'use'
a generic subroutine which takes a variable name and looks at it's caller's package to see if that variable is defined and if it's defined, returns it's valueSomething like this should do (also complies with strictures too).
Note, this will only work with scalar value types.sub isdef { my($var, $pkg) = ( shift, scalar(caller)."::" ); return unless defined $main::{$pkg}; return unless defined $main::{$pkg}{$var}; return unless defined *{ $main::{$pkg}{$var} }{SCALAR}; return ${ *{ $main::{$pkg}{$var} }{SCALAR} }; }
_________
broquaint
|
|---|