Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: multiple local vars in a foreach loop

by LanX (Chancellor)
on Jan 31, 2013 at 11:28 UTC ( #1016294=note: print w/replies, xml ) Need Help??

in reply to Re: multiple local vars in a foreach loop
in thread multiple local vars in a foreach loop

Right answer to wrong question! ;-)

DB<156> while (my ($key, $value) = each @a) { print "$key, $value" } +;; Type of arg 1 to each must be hash (not array dereference) at (eval 13 +5)[] line 2, near "@a) "

Cheers Rolf

Replies are listed 'Best First'.
Re^3: multiple local vars in a foreach loop
by choroba (Chancellor) on Jan 31, 2013 at 11:30 UTC
    Depends on the version of Perl: each.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Unfortunately not! :(

      This doesn't help splicing multiple loop vars...


      it will also return the index and value for the next element of an array so that you can iterate over it;

      Wrong answer wrong question! ;-)

      Cheers Rolf

        You are right. Heh, sometimes one should remember the original question, not only read a reply.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016294]
Corion looks at TheDamians new modules. It seems he's written another Perl parser in a regexp and uses it for Keyword::Declare ...
[Discipulus]: from txt to array, from array to polemic, from polemic to flame?
[Corion]: Discipulus++ # profound insight
[Corion]: :-D

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-06-23 07:54 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (536 votes). Check out past polls.