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")

In reply to (tye)Re: Precedence of grep vs. ?: by tye
in thread Precedence of grep vs. ?: by blackjudas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.