in reply to Is this system call hazardous for my computers health??

Expanding a little on chromatic's reply...

To remove all the files within the directory, you'd need to append the '*' to the path name to expand it to file names just within that directory. Plus, you'd have to concatenate it into a single argument so that system() will see the '*' and pass the whole thing through the shell for expansion:
system("rm -rf $tmp_dir/*");
The '/' separator is UNIX-specific, though, so if portability is important you'd want to:
use File::Spec; system("rm -rf " . File::Spec->catfile($tmpdir, "*"));
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::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";
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.

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
    which I can only imagine in the unusual case where you can't create a new directory in /tmp.

    Or if ownership and/or permissions were set up by a more privileged user.