in reply to I hate nested loops

It's hard to beat nested foreach loops for simplicity and readability in the example you provided. But if there is a Perl5 alternative, it's probably found in tye's Algorithm::Loops. In specific, you could accomplish the same like this:

NestedLoops( [ \@eths, \@nets ], sub{ $netfaces->{ $_[0] }{ $_[1] } = 1; } );

Your posted example is what everyone's going to expect to see. But I would guess that any reasonably experienced programmer would be able to look at the snippet posted in this node and know pretty quickly what is going on.


Dave

Replies are listed 'Best First'.
Re^2: I hate nested loops
by rastoboy (Monk) on Aug 10, 2011 at 21:05 UTC
    Awesome, y'all, thanks!

    I don't want to obfuscate it or anything, I really just had an (apprently wrong) intuition that there ought to be a nice, non-obfuscated way of making it more elegant.

    I used to have a nested loop problem, which Granfather here on PM talked me out of, and I've been so much happier, since :-)