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

Re: [MacPerl] Deleting a file



D. Beverly wrote:

> unlink $pic;        # the file is gone

Which is probably totally clear, unless you're new to perl.
So just to clarify. You unlink file specs, not file handles.
[apologies if I'm being redundant]


I also wanted to comment on:

> At any rate, be sure you really do want to delete the
> file, because in MacPerl there's no second chance. 
> It's gone.

Here's a totally un-portable, yet very mac-like alternative
to unlink'ing a file... dump them in the trash.

The following code snippet should demonstrate how to do this
quite simply. This example, when saved as a droplet, moves
whatever is dropped on it to the trash. Of course, normally
you would replace $ARGV[0] with the filespec of whatever file
you want to remove.

...................................................................

#!perl -w

use Mac::Files;

FSpCatMove($ARGV[0], FindFolder(kOnSystemDisk, kTrashFolderType));

...................................................................


jay

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org