perlquestion
blakem
Sometimes <code>while(...)</code> magically deparsed to <code>while(defined(...))</code>, but sometimes it doesn't. How is this decision made?
<code>
#### GLOBS cause defined to show up
# while(<*.pl>) {} DEFINEDNESS
% perl -MO=Deparse -e 'while(<*.pl>) {}'
while (defined($_ = CORE::GLOBAL::glob('*.pl', 0))) {
();
}
# 1 while (<*.pl>) DEFINEDNESS
% perl -MO=Deparse -e '1 while(<*.pl>)'
'???' while defined($_ = CORE::GLOBAL::glob('*.pl', 0));
#### Simple vars dont
# while($x) {} TRUTHFULNESS
% perl -MO=Deparse -e 'while($x) {}'
while ($x) {
();
}
# '1 while($x)' TRUTHFULNESS
% perl -MO=Deparse -e '1 while($x)'
'???' while $x;
#### Why do these two behave differently????
# 'while($x = <*.pl>) {} DEFINEDNESS
% perl -MO=Deparse -e 'while($x = <*.pl>) {}'
while (defined($x = CORE::GLOBAL::glob('*.pl', 0))) {
();
}
# '1 while($x = <*.pl>) TRUTHFULNESS
% perl -MO=Deparse -e '1 while($x = <*.pl>)'
'???' while $x = CORE::GLOBAL::glob('*.pl', 0);
</code>
I looked for documentation on this behaviour but couldn't find any. Flow control keywords aren't listed in [perlfunc], do they have their own perldoc page?
<P>
-Blake