find sub { my $numb = (fileparse($_,'.txt'))[0]; return unless $numb =~ /^\d+$/; push @ARGV, $File::Find::name if $numb >= $start and $numb <= $end; }, $dir; #### opendir DIR, $dir or die "Failed to open directory $dir: $!"; foreach my $file (readdir DIR) { # much the same as using fileparse my ($number, $ext) = split /\./, basename($file); next unless $ext eq "txt"; next unless $number =~ /^\d+$/; next unless $number < $start || $number > $end; push @ARGV, "$dir/$file"; } #### { local $, = "\n"; print @ARGC; }