Reputation: 49
Can anyone tell me how to use 2 array together to print in a particular manner?
@array1= "in_1","in_2","in_3";
@array2= "1","0","1";
I want them to be printed in this pattern
in_1 = 1; in_2 = 0; in_3 =1 ;
thanks
Upvotes: 2
Views: 107
Reputation:
Could use a hash slice (associative array)
@ary1 = (a,b,c);
@ary2 = (1,2,3);
%hash = ();
@hash{@ary1} = @ary2;
foreach $key ( keys %hash )
{
print "$key = $hash{$key}\n";
}
Or just a simple loop.
for (0 .. $#ary1)
{
print "$ary1[$_] = $ary2[$_]\n";
}
Upvotes: 0