Home: Perl Programming Help: Beginner:
File deletion



waherne
Novice

Mar 12, 2000, 7:07 AM


Views: 1528
File deletion

Hi,

How do you delete a selected file?

e.g. ./mydir/deletethis.txt

Thanks for any assistance that you can provide.

Willie


Cure
User

Mar 11, 2000, 10:10 PM


Views: 1528
Re: File deletion

Hi waherne

perldoc -f unlink

example(s)::

$path='the/path/directory/;
$file='new.txt';
unlink("$path/$file");


but if your in the same directory as the file you are trying to delete, then do this::


$file='new.txt';
unlink($file);

Cure;