in reply to Statement Modifiers, Whaa?

It's because of precedence.

not have more precedence than the others you're using. You are making this:
return "Get Lost!" if (not $nice) or return "Hi"
while what you want is this:
return "Get Lost!" if not ($nice or return "Hi")



Hopes
$_=$,=q,\,@4O,,s,^$,$\,,s,s,^,b9,s, $_^=q,$\^-]!,,print

Replies are listed 'Best First'.
Compile the source, Luke (Re: Statement Modifiers, Whaa?)
by cmilfo (Hermit) on May 10, 2002 at 03:53 UTC
    This is where the Perl compiler becomes your best friend. If you run perl -MO=Deparse,-p [your script name here], the presedence Perl sees will be printed out. See below for your code example from above, which I stored in hello.pl.
    [cmilfo@cmilfo monks]$ perl -MO=Deparse,-p hello.pl ($nice = 0); sub hello1 { (($nice or return('Hi')) or return('Get Lost!')); } sub hello2 { (((!$nice) || return('Hi')) and return('Get Lost!')); } print(hello1(), hello2()); hello.pl syntax OK
    It basically puts in all the () and {} that we may not see.

    Cheers!
    Casey