in reply to Re: Best way to match items in an array
in thread Best way to match items in an array

An optimization:

my @dlcopy = @dir_list ; my @extensions = qw(zip log whatever) ; my %matches ; foreach my $ext (@extensions) { my $nonmatching = [] ; my $matching = [] ; my $pattern = qr(\.$ext$) ; foreach my $file (@dlcopy) { push @{$file =~ /$pattern/ ? $matching : $nonmatching},$file ; } @dlcopy = @$nonmatching ; $matches{$ext} = $matching ; }

Ciao!
--bronto

# Another Perl edition of a song:
# The End, by The Beatles
END {
  $you->take($love) eq $you->make($love) ;
}