On Tue, Jul 26, 2005 at 11:35:46PM +0200, Abigail wrote: > On Tue, Jul 26, 2005 at 05:37:39PM +0100, Nicholas Clark wrote: > > > > So is "wantarray's value is only specified within a subroutine or method > > which was called directly by other perl code" true? > > No. > > $ perl -wle 'print eval "wantarray"' > 1 > $ > > > No subroutine, no method.
A quick look at the src shows that it scans back through the current context stack for an eval, sub or format. From this perspective, a require or do "file" is an eval. If it it fails to find one, it returns undef. It doesn't scan previous context stacks, so it wont backtrack through magic, tie, overload etc. -- The perl5 internals are a complete mess. It's like Jenga - to get the perl5 tower taller and do something new you select a block somewhere in the middle, with trepidation pull it out slowly, and then carefully balance it somewhere new, hoping the whole edifice won't collapse as a result. - Nicholas Clark, based on an original by Simon Cozens.