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

Re: [MacPerl] Filename globbing



Tom Harrington <tph@shell.rmi.net> writes:
>I have a script which wants to begin by clearing out all of the
>files in a folder, before creating new ones.  On a Unix box, I'd
>use:
>     unlink("./foo/*");

I must point out, first, that this construct is far from portable among
Unix boxes even. unlink() does not normally allow globbing (Nor should it,
IMHO).

>All was well until I switched to a different folder and the 
>unlinking died.  On investigation, the perlop man page says that
>globbing "...will not work on filenames with spaces in them unless
>you have  csh(1) on your machine."  That was it; the new folder 
>had spaces in its name.

Hmm.

>Given that installing csh is not really an option, how can
>I properly glob filenames in a folder whose name includes
>spaces?

It might be possible for me to fix glob.

>(How is globbing implemented in MacPerl anyway?

Hardcoded in the application.

>On Unix systems it uses a shell process).

Used to do that on MacPerl, too.

>On a separate note, is there a function that moves things to
>the trash rather than just deleting them outright?

Mac::Files::FindFolder will get you the trash folder.
File::Copy::move       will move.

All you have to do is figure out how to match trash folders with file paths
and you're in business.

Matthias

-----
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "One fine day in my odd past..." -- Pixies, _Planet of Sound_

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch