in reply to Array compare using elements as the pattern match.
use warnings; use strict; use Data::Dumper; my @array1 = qw(234 453 111 239); my @array2 = qw(v204_txt v234_txt v450_txt v453_txt); my @a3; for (@array2) { for my $pat (@array1) { if (/$pat/) { push @a3, $_; last; } } } print Dumper(\@a3); __END__ $VAR1 = [ 'v234_txt', 'v453_txt' ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array compare using elements as the pattern match.
by Anonymous Monk on Dec 12, 2014 at 21:43 UTC | |
by RonW (Parson) on Dec 12, 2014 at 22:23 UTC | |
by toolic (Bishop) on Dec 13, 2014 at 02:55 UTC | |
|
Re^2: Array compare using elements as the pattern match.
by Anonymous Monk on Dec 12, 2014 at 21:26 UTC |