my %h = map{ reverse /(\d+).*#(.+)/ } grep "@array1", @array2; print Dumper \%h;