How about 

print "$a[$_]:$b[$_] for 0..$#a;

or in the p6 case...

print "@a[$_]:@b[$_]" for 0..$#a;

Ilya


-----Original Message-----
From: raptor
To: [EMAIL PROTECTED]
Sent: 07/18/2001 12:14 PM
Subject: one more nice2haveit

hi,

As I was programming i got again to one thing i alwas needed to have...
especialy when write something fast or debug some result... words comes
about for/foreach and accessing the current-index of the array I'm
working
with .... i.e.

say I have two arrays @a and @b and want to print them (also say they
are
connected in some way so I want to see them both). In case of one array
I
write :

print "$_\n" for @a;

fast, simple, good....but in my case I have to write something like this
:

for ($i = 0; $i < scalar @a; $i++) {
 print "$a[$i] : $b[$i]\n"
};

I've go tired of typing :"), but if I had current index-iterator ( say
under
$i just as example) at hand the way I have $_ i can just type :

print "$_ : $b[$i]\n" for @a;
OR
print "$a[$i] : $b[$i]\n" for @a;

isn't that cute :") ... the same count for list in $i I just get current
position in the list. (we can also use "pos" in some way!!!)

print "$_ : $a[$i] : $b[$i]\n" for (qw(val1 val2 val3));

I need it very often.:")
don't bother if the lenght of both arrays are different.... when u use
it, u
know what u are doing...

=====
iVAN
[EMAIL PROTECTED]
=====


Reply via email to