opendir(TARGET, ".") or die "Can't open current directory: $!"; my @targets= grep $pattern readdir TARGET; my $gzip_count = 0; foreach my $target (@targets) { my $cnt = 0; if (-M $target > $expiration) { $gzip_count++; $cnt = `gzip $target`; } }