in reply to extracting information from arrays
#! /usr/bin/perl use strict; use warnings; use Data::Dumper; # your pairs my @pairs = ([1,2],[3,4],[5,6]); # sources my @array1 = (1,5); my @array2 = (3,6); my @array3 = (2,4); my @locations; for my $pair(@pairs){ my @loc_array; for my $item(@$pair){ my $location; if(grep{$_ == $item}@array1){ $location = "array1"; } elsif(grep{$_ == $item}@array2){ $location = "array2"; } else{ $location = "array3"; } push(@loc_array,$location); } push(@locations,\@loc_array); }
|
|---|