Yes! And use Basename too.

these will also give you the advantage of making your programs more
portable!

-Tom Kinzer


-----Original Message-----
From: John W. Krahn [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 11:37 AM
To: [EMAIL PROTECTED]
Subject: Re: file path pattern matching problem.


Ben Crane wrote:
>
> Hi all,

Hello,

> I'm trying to split apart a filepath...e.g:
> c:\test\abc\what\somefile.txt
> The length of the filepath will never be constant...


$ perl -le'
use File::Spec;

my $path = q[c:\test\abc\what\somefile.txt];

my ( $vol, $dir, $file ) = File::Spec->splitpath( $path );
print qq[ "$vol"  "$dir"  "$file" ];

my @dirs = File::Spec->splitdir( $dir );
print map qq[ "$_" ], @dirs;

'
 "c:"  "\test\abc\what\"  "somefile.txt"
 ""  "test"  "abc"  "what"  ""



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to