in reply to comparing element in arrays

You could try something like this:

my %numbered; foreach my $string (@a) { for ($string =~ /(\d+)/g) { push @{$numbered{$_}}, $string; } } my @occurances; for (@b) { push @occurances, @{$numbered{$_}} if exists $numbered{$_}; }
Rough code, untested. Your data may allow some simplification.

After Compline,
Zaxo