Assuming that the first part of each @fileslist element will have that scheme:
use strict;
use warnings;
use Smart::Comments;
my @datelist = ( "20030901", "20061017", "20050406", "20070101", "2008
+0202" );
my @fileslist = (
"DIR22.20060816", "DIR22.20050919", "DIR22.20061017", "DIR22.20060
+516",
"DIR22.20050406"
);
# creates a hash with all dates seen on @fileslist
my %seen_dates;
@seen_dates{ map { ( unpack( "x6A*", $_ ) )[0] } @fileslist } = ();
# increases the value of each seen @datelist element on %seen_dates.
foreach (@datelist) {
if ( exists $seen_dates{$_} ) {
$seen_dates{$_}++;
}
}
# search for defined values for each %seen_dates key.
my @seen_dates = grep { defined $seen_dates{$_} } keys %seen_dates;
### @seen_dates
Igor 'izut' Sutton
your code, your rules.