Here is a post of what I used ...(Mike Blezien's example)
my $DIR = 'D:/server/work';
my($deletefile,$removefile);
opendir (DIR, "$DIR") or die $!;
my @files = grep(/\.(dat|p1)/i,readdir(DIR));
closedir (DIR);
foreach $removefile (@files)
{
$deletefile = $DIR . "/" . $removefile;
unlink $deletefile if -e $deletefile;
}
Again thanks to all that replied...
Mike....
-----Original Message-----
From: John W. Krahn [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 15, 2002 9:35 AM
To: [EMAIL PROTECTED]
Subject: Re: deleting files
Michael Pastore wrote:
>
> Hello All,
Hello,
> Just a quick question on deleting files in Perl.
>
> I am trying to delete some files in a directory, but I do not know their
> names...just ending extension...
>
> I have tried:
>
> One way:
>
> unlink <*.dat>;
> unlink <*.p1>;
>
> Another way:
>
> unlink glob(".dat");
> unlink glob(".p1");
Both of those methods should work as long as you have permissions to
unlink those files. A more robust method would be:
unlink $_ or warn "Cannot unlink $_: $!" for <*.dat>;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]