in reply to Getting pair of values from an array

Don't forget a recursive solution ...

sub foo { my ($var, $val, @therest ) = @_; if ( !$val ) { return; } else { print "var = $var val = $val\n"; foo ( @therest ); } } my @array = (a=>1, b=>2, c=>3 ); foo (@array);

--
Its like a dog that can sing and dance.
It's remarkable because it can do it.
Not that it can do it well.

Replies are listed 'Best First'.
Re: Re: Getting pair of values from an array
by chip (Curate) on Dec 27, 2001 at 10:30 UTC
    Unless you're taking advantage of some tail-recursion optimization that I haven't heard about, recursion is probably a very bad idea for general-purpose iteration....

        -- Chip Salzenberg, Free-Floating Agent of Chaos

      Funny, I had mistaken the signature for a comment on the solution offered, and not a general signature.

      It does fit and address your point, does it not?

      (For the confused, the node under discussion is the grandparent of this node, not the parent.)