in reply to array element as foreach iterator

I have to admit - I've never thought about doing this ... but I can see how that would be some really nice-tasting syntactic sugar.... I would normally look at it this way:

#! user/bin/perl use warnings; use strict; my @x = ( [1,1], [2,2], [3,3] ); sub do_something {} # so, I use this method instead foreach my $a1 (@x) { foreach my $a2 (@x) { do_something($a1, $a2); } }

But maybe that's just me thinking "inside the box" again.

Replies are listed 'Best First'.
Re^2: array element as foreach iterator
by kingm61 (Initiate) on Jan 27, 2005 at 17:29 UTC
    Yes, that too was my first thought. But, I actually had 10 nested foreach loops, and the programmer inside said "sounds like an array", so I tried to use elements of an array as the iterators. As always, TMTOWTDI.
      I actually had 10 nested foreach loops, and the programmer inside said "sounds like an array"

      The programmer inside me says "sounds like recursion".