I stand corrected, Eily and hippo are right, the sub can only see closed over variables, I didn't try the code, mea culpa
I don't understand your question, what is natively supposed to mean?
Both func return the same $x.
$y = $myscalar; is the only important but non effective difference.
the straightforward way to implement this is an exported getter
sub get_myscalar { return $myscalar }
If you really have too many individual lexicals to be handled by getters, you probably want to hold them in a hash instead.
my %exported_lex ={ myscalar => \$myscalar, myscalar2 => \$myscalar2, } sub get_lex_ref { return $exported_lex{$_[0]} } sub get_lex_val { return ${$exported_lex{$_[0]}} }
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery
In reply to Re: eval in perl package (updated getter %exported_lex) )
by LanX
in thread [SOLVED]: eval in perl package
by MarcusE
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |