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

Re: [MacPerl-Porters] globbing



On Wed, 29 Dec 1999 05:55:15 -0500, Scott R. Godin wrote:

>does anyone know offhand whether the current version of MacPerl (I just got
>the "Power and Ease" book :) has been updated to include full globbing
>patterns such as [a-zA-Z] etc  ? or is it still just * and ?

File globbing is supposed to be shell-compatible. That is pretty
meaningless for MacPerl (unless you count on LWP), but on other
platforms, shell globbing is based on '*' and '?'. So it is very
unlikely that it will EVER change.

If you want a more powerful globbing, you must build your own, with
readdir() + grep(). Something like this:

	opendir DIR, $dir;
	@globbed = grep { /^[a-z]{1,3}\d+$/ } readdir DIR; # bare names
	@fullpaths = map { "$dir:$_" } @globbed; #full paths
	closedir DIR;

Of course, the third statement (map) is platform-specific for the Mac.
The module File::Spec can uplift that limitation.

-- 
	Bart.

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