Just another Perl shrine | |
PerlMonks |
It's a bug (was: When does while() test for defined vs truth)by robin (Chaplain) |
on Dec 17, 2001 at 20:23 UTC ( [id://132548]=note: print w/replies, xml ) | Need Help?? |
Update: Jarkko has now applied this patch, so it'll be fixed in the next version of perl.
As several other respondents have noted, certain constructs should always be treated as implicit definedness tests when used in the loop condition of a while loop. Those constructs are:
What blakem pointed out is that this isn't working consistently, and if you write a loop of the form 1 while $variable = glob('*.pl'), then the test isn't wrapped in a defined() call, as it should be. It's a bug in perl. A typo in the newLOOPOP function of op.c, to be precise. It can be fixed by applying the following patch (against bleadperl). I'll send the patch to p5p, and it ought to go into 5.8. Well spotted, blakem!
In Section
Seekers of Perl Wisdom
|
|