in reply to GREP case insensitivity

If you are using the grep function simply to grab the items in a list that match a particular pattern, you don't even need the curlies:
my @bintext2 = grep /$input/i, @bintext;
(note the comma after the regex)

You only need curlies if you are using grep with a code snippet (item is selected if the code returns true) -- e.g.:

my @bintext2 = grep { /$input/i and length()>20 } @bintext;
(note: no comma after the code block)

Replies are listed 'Best First'.
Re^2: GREP case insensitivity
by jwkrahn (Abbot) on Nov 14, 2008 at 01:59 UTC
    You only need curlies if you are using grep with a code snippet

    The reason your example needs curlies is because the  and operator has lower precedence than the comma operator.   If you use the  && operator then a comma works.

    my @bintext2 = grep /$input/i && length > 20, @bintext;