develooper Front page | perl.perl5.porters | Postings from August 2001

Re: minor File::Spec questions

Thread Previous
From:
Barrie Slaymaker
Date:
August 21, 2001 08:35
Subject:
Re: minor File::Spec questions
Message ID:
20010821113508.A15795@jester.slaysys.com
On Tue, Aug 21, 2001 at 08:33:24AM -0400, David Boyce wrote:
> 
> I'll put it on my list, no promises or dates though.

Cool, thanks.

> I agree about the weird OO interface but this drifts from my major point. 

Yup, sorry, it was pre-caffeine...

> Would it not make sense to fold File::Basename into File::Spec and 
> deprecate the former while leaving it as a compatibility wrapper?

I think something like it would be nice, not sure what the most
appropriate interface is.  Some options:

   ( $vol, $dirs, $name, $ext ) = splitpathext( $path, $ext_pattern ) ;

for the general case, and 

   ( $vol, $dirs, $name, $ext ) = splitpathext( $path ) ;

for the "default", where the extension pattern is whatever's natural to
the local OS.

That's a bit cumbersome, but cross-platform stuff is cumbersome.
Perhaps (also?) a 

   ( $path, $ext ) = splitext( $path, [$ext_pattern] ) ;

([] = optional, not ARRAY ctor) or just a 

   $ext = get_ext( $path, [$ext_pattern] ) ;

I often just use fileparse to peek at an extension, or to strip it off
and replace it, so the splitext() and a corresponding catext() would do
the trick for most of my uses.

Just some thoughts,

Barrie

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About