Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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?
[LanX]: headshot ?
LanX s English not humorous enough

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2017-10-18 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (245 votes). Check out past polls.

    Notices?