my @list; foreach my $file () { foreach (split /,/, $file) { m/(AAA\.\d)/; push @list, $1; } }