in reply to next in a post-fixed for

FWIW #1: The thing that gets me isn't the "next", but all the nested dereferences, which are hard to parse.

FWIW #2: It seems like you're doing things backwards. Wouldn't this be more straight-forward?

for $t (@t) { $y{$t} = [grep /$t/, @f] }
Update: c.f. jdalbec's response, I didn't read the OP's node carefully enough (probably because #1 is so true... ;).

Replies are listed 'Best First'.
Re^2: next in a post-fixed for
by Codon (Friar) on Jul 07, 2007 at 07:19 UTC
    The above code was just prototype code; the actual code was getting the list of strings (@f) from a readdir. This was one of the original motivators for having the outer looping construct be over @f.

    Ivan Heffner
    Sr. Software Engineer
    WhitePages.com, Inc.
Re^2: next in a post-fixed for
by jdalbec (Deacon) on Jul 06, 2007 at 23:22 UTC
    The OP's code associates each string only to the first pattern that it matches. Your simplification associates each string to each pattern that it matches. Also, if there are many patterns, the OP's code lends itself to optimization via study().