Another way ...
opendir REMOVEIT, $dir or die "Open Failed";
my @gone = grep /\.bak$/ , map "$dir/$_". readdir REMOVEIT;
closedir REMOVEIT;
print "Remove ", join(',', @gone), "? :";
my $cnt;
if (<> =~ /y/i) {
$cnt = unlink @gone;
print "Removed $cnt files from $dir ending in .bak\n" if ($cnt);
}
print "Nothing removed from $dir\n" unless $cnt;
or
chdir "$dir" or die "ChDir failed";
print "Remove ", join(',', <*.bak>), "? :";
my $cnt;
if (<> =~ /y/i) {
$cnt = unlink <*.bak>;
print "Removed $cnt files from $dir ending in .bak\n" if ($cnt);
}
print "Nothing removed from $dir\n" unless $cnt;
-----Original Message-----
From: Sara [mailto:[EMAIL PROTECTED]
Sent: October 29, 2003 15:45
To: beginners-cgi
Cc: [EMAIL PROTECTED]
Subject: unlink help.
unlink <*.bak>;
how I am supposed to specify directory above?
for example I have to apply above unlink command to delete all backup files
in the Specified directory.
$dir = /home/path/to/dir
is it right?
unlink <$dir/*.bak>;
??
Any ideas?
Thanks,
Sara.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]