[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [MacPerl] Deleting files??



+
+  How do you delete a file in Perl (perl 4 if it makes a diff)?
+
unlink() is the trick. As an example, the following script will clean out
the preferences:Perl:Temp folder. Unfortunately, unlinik() doesn't zap
folders or locked files.

#
# CleanTemp.pl
#
#    Remove the contents of the Temp folder
#
require "FindFolder.pl";                                                        # used to locate directories

$base_dir = &MacPerl'FindFolder("P") . "Perl:";         # base directory pointer
$temp_dir = $base_dir . "Temp";                                                     # general temporary store

opendir(TEMPDIR, $temp_dir);
@kill_list = readdir(TEMPDIR);
closedir(TEMPDIR);

chdir($temp_dir);
unlink @kill_list;

&MacPerl'Quit(2);


---
mark. (mark_probert@optus.com.au ph +61 2 342 8502 fax +61 2 342 7500)