Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Passing multiple arrays to foreach loop

by AnomalousMonk (Canon)
on May 11, 2013 at 04:08 UTC ( #1033080=note: print w/replies, xml ) Need Help??


in reply to Passing multiple arrays to foreach loop

The only situation in which you will get into trouble is if you include an honest-to-goodness list literal in your for-loop iteration list and then try to do some mutating operation on it.

>perl -wMstrict -le "my @ra1 = qw(foo bar); my @ra2 = qw(does not get here); ;; for my $file (@ra1, 'zonk', @ra2) { $file .= '-appendage'; print qq{'$file'}; } " 'foo-appendage' 'bar-appendage' Modification of a read-only value attempted at -e line 1.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1033080]
help
Chatterbox?
[Discipulus]: how I can tell in which perl version was included List::Util 1.29 ?
[Discipulus]: to specify use 5.0.x to be sure to have pairmap from the module..
[Corion]: Discipulus: I think Module::Corelist ( or corelist ) can tell you that
[Corion]: Meh - Module::CoreList
[choroba]: Just use List::Util 1.29
[choroba]: Be kind to people using old Perl with newer version of the module
[Corion]: But why not simply specify 'List::Util' => 1.29 in your prerequisites? People might install a more recent version of the module into their Perl
[Corion]: (what choroba said)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-05-25 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?