Perl: the Markov chain saw | |
PerlMonks |
warnings pragma anomalyby Athanasius (Archbishop) |
on Oct 17, 2015 at 04:17 UTC ( [id://1145179]=perlquestion: print w/replies, xml ) | Need Help?? |
Athanasius has asked for the wisdom of the Perl Monks concerning the following question: It is completely unimportant. That is why it is so interesting. While researching Re^3: Perl assign scalar to array I noticed something strange. In this one-liner:
the term (2, 3, 4) is evaluated in scalar context, so the comma operator (which is left-associative) twice “evaluates its left argument, throws that value away, then evaluates its right argument and returns that value.” The first two constants are thrown away, so the warning messages are exactly as expected. But when certain constants are used, the warning messages for those constants disappear. I have found three such constants: 0, 1, and undef. For example:
Deparsing sheds no light, since the result is the same in all cases:
I tested this on the earliest and latest Perls currently installed on my system: v5.14.4 and v5.22.0 (both Strawberry Perl running under Windows 8.1, 64-bit). Any ideas as to why these three particular constants should be treated differently by the warnings pragma? I tried looking at the code in warnings.pm, but, as far as I can see, the only effect of use warnings is to call warnings::import, which in turn sets ${^WARNING_BITS}. Presumably, this variable affects the behaviour of the perl executable? Does anyone know where in the source code the real functionality behind use warnings resides? Cheers,
Back to
Seekers of Perl Wisdom
|
|