/^(\d+).*/ #### my %uniquelist; my %deletelist; my $h = 0; foreach my $pic (@filelist) { next unless ($pic =~ /\.jpg$/); if( $pic =~ /^(\d+)\.(\d+)/) { my ($num,$counter) = ( $1,$2); $h++; $uniquelist{$num}++; next if ($currentlist{$num}); $deletelist{$pic}++; } else { print STDERR "saw a photo file ($pic) that did not match the expected naming pattern!\n"; } }