in reply to Unusual 'constant in void context' warnings

That is because those two lines are not doing anything. There is nothing to check since the if comparison is undefined.
  • Comment on Re: Unusual 'constant in void context' warnings

Replies are listed 'Best First'.
(MeowChow) Re2: Unusual 'constant in void context' warnings
by MeowChow (Vicar) on Mar 29, 2002 at 23:45 UTC
    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

      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.