Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: tcl like 1 loop with two operators

by Mask (Pilgrim)
on Jan 25, 2011 at 15:14 UTC ( #884137=note: print w/replies, xml ) Need Help??


in reply to Re: tcl like 1 loop with two operators
in thread tcl like 1 loop with two operators

Or in case if arrays with $i and $j values are predefined, I would write it like that:
my @i=(1,2); my @j=(3,4); my @a = map {[$i[$_],$j[$_]]} 0..$#i; foreach my $ij (@a){ my ($i, $j) = @{$ij}; say $i; say $j; }
OR if it's necessary to emulate TCL behaviour for different lengths of arrays with $i and $j values, I would write it like that:
my @i=(1,2); my @j=(3,4,5); my @len = sort(scalar(@i),scalar(@j)); my @a = map {[$i[$_],$j[$_]]} 0..$len[-1]; foreach my $ij (@a){ my ($i, $j) = @{$ij}; print $i."\n"; print $j."\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://884137]
help
Chatterbox?
[Corion]: Oooh. I had hoped that X::Tiny would be an X11 client or X11 server, but it is an exception framework :-)
[MidLifeXis]: How many languages would that 'Ex' alias handle. ETOOCUTE

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-02-27 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (383 votes). Check out past polls.