Hi jet speed, On Wed, 5 Sep 2012 11:47:41 +0100 jet speed <speedj...@googlemail.com> wrote:
> Hi All, > > I would like to print array1 with array2 as below ex: > > output > ----------- > abc-12 20/1 > def-22 30/22 > ghi-33 40/3 > def-22 20/1 > The best way would be to iterate over the indexes: for my $idx (0 .. $#array1) { print $array1[$idx], "<=>", $array2[$idx], "\n"; } > @array1 ="abc-12, def-22, ghi-33,abc-12,def-22"; > @array2 ="20/1, 30/22, 40/3, 20/1"; That's the wrong way to initialise arrays. It will initialise them as big strings. Are you making up syntax? > > i did try to map array1 to array2 elements, did'nt work. > > %hash = map {$array1[$_] => $array2[$_] } (0..$#array1); > Since you are putting them in a hash, the order will be lost because a hash is unordered. > please advice, how can i print the corresponding elements of @array1 > and @array 2, as in the the output above. See above. Regards, Shlomi Fish > > Thanks > > Sj -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ List of Portability Libraries - http://shlom.in/port-libs You name it — COBOL does not have it. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/