in reply to Does a file really exist?

Slightly different input spec to your code ( and very simplistic output ), but this could easily be modified to suit. Abigail deserves the credit for the leap year code.

#!/usr/local/bin/perl -w use strict; my $lastday= sub { $_[0] == 1 and return ( $_[0] % 4 ? 28 : $_[0] % 100 ? 29 : $_[0] % 400 ? 28 : 29 ); return ( qw~ 31 0 31 30 31 30 31 31 30 31 30 31 ~ )[$_[0]]; }; my $mon = $ARGV[0] ? $ARGV[0]-1 : (localtime( time ))[4]; my %days; @days{ 1 .. $lastday->($mon) } = (); opendir DIR, './' or die "Can\'t read from dir:$!"; for ( grep { /^.*?_weather/ } readdir DIR ) { my $day = $1 if /^(\d+?)-/; delete $days{$day} if $day; } close DIR; print map { join '' => $_, "\n" } sort { $a <=> $b } keys %days; __END__