On 2012-09-05 12:47, jet speed wrote:

output
-----------
abc-12 20/1
def-22 30/22
ghi-33 40/3
def-22 20/1

@array1 ="abc-12, def-22, ghi-33,abc-12,def-22";
@array2 ="20/1, 30/22, 40/3, 20/1";

i did try to map array1 to array2 elements,  did'nt work.

%hash = map {$array1[$_] => $array2[$_] } (0..$#array1);

perl -Mstrict -wle'
  my @keys = qw{ abc-12  def-22  ghi-33  def-22 };
  my @values = qw{ 20/1  30/22  40/3  20/1 };

  my %kv;
  @kv{ @keys } = @values;

  print qq{$_ $kv{ $_ }} for @keys;
'
abc-12 20/1
def-22 20/1
ghi-33 40/3
def-22 20/1

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to