in reply to Concise foreach expression

In this case you could use grep:

print "$_\n" for grep {/test$/} @names;

UPDATE: ...or more cryptically: /test$/ and print "$_\n" for @names;.

Replies are listed 'Best First'.
Re^2: Concise foreach expression
by toolic (Bishop) on Aug 29, 2014 at 12:17 UTC
    That produces different results from the OP's code. Yours prints out elements of the @names array, but the OP prints out $path_name multiple times.

      Thanks! I did really see what I wanted to see and did not read carefully enough!

        > I did really see what I wanted to see

        don't bother, you saw what the OP meant ... :)

        Cheers Rolf

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