in reply to BEGIN { } block
doesn't compile, buta my ($b, $c)
does (assuming package A exports subroutine a). How can the use statement affect compilation? It couldn't, without BEGIN {}!use A qw/a/; a my ($b, $c);
The point is that Exporter->import defines a (probably via some clever version of eval 'sub ' . caller . '::' . $to_be_imported *) at compile time.
For an even subtler example of the nastiness that can occur, note that
does compile, but not as you'd expect—the ‘indirect object’ syntax causes it to be compiled asmy ( $b, $c ); a $b, $c;
$b->a($c)
* At least, I think that that's what happens; I got tired reading the Exporter source and didn't find out for sure. :-)
|
---|