in reply to Is this system call hazardous for my computers health??
The '/' separator is UNIX-specific, though, so if portability is important you'd want to:system("rm -rf $tmp_dir/*");
However, removing files within a temporary directory this way is a little laborious. If the whole directory is really temporary, it's more usual to just blow it away and recreate it. You can do this very simply (and without using an external command) as follows:use File::Spec; system("rm -rf " . File::Spec->catfile($tmpdir, "*"));
This works unless you really must re-use the existing temporary directory itself, which I can only imagine in the unusual case where you can't create a new directory in /tmp.use File::Path; my $tmp_dir = "/tmp/blahblah-11-14-2000"; rmtree($tmp_dir); # no error check; doesn't matter if it doesn' +t exist mkdir($tmp_dir) or die "Unable to make temporary folder $tmp_dir: +$!\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Is this system call hazardous for my computers health??
by Fastolfe (Vicar) on Nov 15, 2000 at 20:50 UTC |