The package of a line of code is set when that line is compiled.
Furthermore, package is lexically scoped, so you can't just put the eval in a BEGIN.
You can do
my $p = 'Package'; my $c = 'print(__PACKAGE__);'; # Some code eval "package $a; $c";
In reply to Re^2: How not to hardcode a package name?
by ikegami
in thread How not to hardcode a package name?
by blazar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |