--- "Porter, Chris" <[EMAIL PROTECTED]> wrote:
> Any ideas???????
> > me. I want to create a script that deletes uppercase words from a
> > directory using the unlink command. Probably a very simple thing
chdir $dir or die $!;
opendir DIR, "." or die $!;
for my $file (grep { -f $_ } readdir DIR) { # maybe -c?....
unlink $file if $file =~ /^[A-Z]+$/
}
closedir DIR;
Print files might be character special files, with would be -c, or some
other sort that would simplify the grep test to a more accurate
version.
What this does:
chdir $dir or die $!;
Go to the directory in question. This assumes you've already loaded
$dir with that name.
opendir DIR, "." or die $!;
Open the current directory for reading, to get the filenames.
for my $file (grep { -f $_ } readdir DIR) { # maybe -c?....
Loop through the files (for my $file) in the directory (readdir DIR)
that are plain files (grep { -f $_ })
--- note that this grep condition is the one that might need to be
changed to -c instead of -f ---
unlink $file if $file =~ /^[A-Z]+$/
and unlink each $file returned.
=====
print "Just another Perl Hacker\n"; # edited for readability =o)
=============================================================
Real friends are those whom, when you inconvenience them, are bothered less by it than
you are. -- me. =o)
=============================================================
"There are trivial truths and there are great Truths.
The opposite of a trival truth is obviously false.
The opposite of a great Truth is also true." -- Neils Bohr
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/