in reply to Concise foreach expression

Your original foreach loop is probably the clearest, but if you do want fewer characters, you could go for something less readable like:
print"$path_name\n"for grep/test$/,@names;

I doubt it runs faster.

Replies are listed 'Best First'.
Re^2: Concise foreach expression
by ikegami (Patriarch) on Aug 29, 2014 at 19:01 UTC
    print"$path_name\n"x grep/test$/,@names; say$path_name x grep/test$/,@names;
    /test$/&&print$path_name,$/for@names; /test$/&&say$path_name for@names;

    If he meant $x where he had $path_name,

    print"$_\n"x grep/test$/,@names; say for grep/test$/,@names;
    /test$/&&print$_,$/for@names; /test$/&&say for@names;
    print/.*test$/g,$/ for@names; say/.*test$/g for@names;