in reply to Precedence of grep vs. ?:

See

$ perl -MO=Deparse $f= grep {/f/} @array ? 1 : 2; <EOF> $f = grep({/f/;} @array ? 1 : 2);
Note that you have other options beside what you listed. I'd have chosen: $f= grep( /f/, @array ) ? 1 : 2;

You were on the right track as to the source of your problem with your node title (originally just "precedence"). To quote bits from "perldoc perlop":

left terms and list operators (leftward) [...] right ?: [...] nonassoc list operators (rightward) [...] Terms and List Operators (Leftward) A TERM has the highest precedence in Perl. They include [...] any function whose arguments are parenthesized. [...] List Operators (Rightward) On the right side of a list operator, it has very low precedence, such that it controls all comma-separated expressions found there. The only operators with lower precedence are the logical operators "and", "or", and "not", which may be used to evaluate calls to list operators without the need for extra parentheses: open HANDLE, "filename" or die "Can't open: $!\n";
which means that list operators bind tighter than ?: if you use parens but looser if you don't.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Precedence of grep vs. ?:
by blackjudas (Pilgrim) on Oct 05, 2001 at 09:56 UTC
    Thanks for your help tye! I get it now, I'll have to scan the docs more carefully next time. Though I must admit, sometimes hard to find the exact answer if you're not too sure what you're looking for :).

    BlackJudas