in reply to Re: Unusual 'constant in void context' warnings
in thread Unusual 'constant in void context' warnings

There is nothing undefined about the comparison. The comparison evaluates to false. Perl will usually optimize out the entire statement from the parse tree when this happens to a constant test, as is the case with the "1f" line. What is interesting in this case is that perl leaves a remnant behind in the parse tree/bytecode (as Deparse seemingly indicates), presumably the constant which is being tested. This is consistent with the output of the following code:
  
#!/usr/bin/perl -w 0; 1; '0';
I believe this warning is a (very minor) bug, since the print+comparison statement should be optimized out of the parse tree entirely.
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: (MeowChow) Re2: Unusual 'constant in void context' warnings
by Marza (Vicar) on Mar 30, 2002 at 01:17 UTC

    I am not sure it is a bug.

    Does this not fall under the "if it looks like a function..." rule?

    Nothing was getting stored anywhere so Perl discarded it.

    If you were to change to

    my $a = '0'; print "3f\n" if $a;
    You don't get output. But you don't get the error.