#!/usr/bin/perl -w
use strict; #use diagnostics;
my $dir = "testdir"; opendir (DH, "$dir") || die "Could not open $dir: $!\n";
my @files; my $keep = 7; while (defined(my $file = readdir(DH))){ next if $file =~ /^\.+$/; push (@files, $file); }
# Skip the rest if number of files isn't above $keep.
chdir $dir; if ($#files -1 > $keep){
If you have ten files in @files then "@files == 10" and "$#files == 9" so you are comparing $keep to the number of files minus two.
$ perl -le' $keep = 7; $#{$x[$_]} = $_ + 4 for 0 .. 8;
for ( @x ) { my @y = @$_; if ( $#y - 1 > $keep ) { print "True: " . @y . " ", $#y - 1; } else { print "False: " . @y . " ", $#y - 1; } } ' False: 5 3 False: 6 4 False: 7 5 False: 8 6 False: 9 7 True: 10 8 True: 11 9 True: 12 10 True: 13 11
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>