in reply to Build a list of files that are NOT in a list

Are you sure you want to do
/^(\d+).*/
If I understand your name construction properly you expected NNNN.NNNN.jpg

I would write the code slightly more carefully (your 1st foreach loop) note the \.

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 expect +ed naming pattern!\n"; } }
Code suggestion, you might want to replace my $k = 0 + keys %uniquelist; with my $k = scalar keys %uniquelist;, as some may feel this is more explicit.