in reply to Concise foreach expression

Unfortunately, statement modifiers cannot be chained. From perlsyn (emphasis in original):

Any simple statement may optionally be followed by a SINGLE modifier, just before the terminating semicolon (or block ending).

In this specific case, you can use grep or map instead, though.

say foreach (grep /test$/, @names); map { /test$/ and say } @names;

Edit: toolic's remark in Re^2: Concise foreach expression also applies to the above two lines: they'll print the matching @names, not multiple copies of $path_name.

Replies are listed 'Best First'.
Re^2: Concise foreach expression
by LanX (Saint) on Aug 29, 2014 at 13:01 UTC
    > map { /test$/ and say } @names;

    variation:

    /test$/ and say for @names;

    ( of course always with use feature 'say';)

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

      TMTOWTDI at its best!