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 |