in reply to Re: if modifier of a print statement
in thread if modifier of a print statement

davorg is right. This is a precedence issue.

using 'and' instead of '&&' lowers the operator precedence.

The first one is interpreted as:
print $_ . ("\n" && next) if /no_proc/;

The fixed one is intepreted as:
(print $_ . "\n") and next if /no_proc/;

Note that the brackets include the print statement, not just the parameters.

Replies are listed 'Best First'.
Re^3: if modifier of a print statement
by jwkrahn (Abbot) on Jun 30, 2009 at 15:03 UTC
    The first one is interpreted as:
    print $_ . ("\n" && next) if /no_proc/;

    The  . operator has higher precedence than the  && operator so it is actually interpreted as:

    $ perl -MO=Deparse,-p -e' print $_ . "\n" && next if /no_proc/; ' (/no_proc/ and print((($_ . "\n") && next))); -e syntax OK