On Jan 5, 2004, at 2:23 AM, [EMAIL PROTECTED] wrote:

I tried explicitly declaring DIR as an array, but I guess handles don't do that. How do I load all of the directory into an array, or more specifically why am I only getting half?

#!/usr/bin/perl


use strict;
use warnings;

my $dir = shift; # call with script_name directory_to_clear

opendir DIR, $dir or die "Directory error:  $!";
my @files = grep /^klee/, readdir DIR;  # load @files
closedir DIR;

# uncomment the following line if you would like a print out of how many files we found
# print "Files found: ", scalar(@files), "\n";
# uncomment the following line if you would like to see all files found
# print "$_\n" foreach @files;


print "Files deleted: ", unlink(map { "$dir/$_" } @files), "\n";

__END__

Hope the helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to