better...(assuming the filename would never have a stupid / in it)
($drive, $path, $file) =  ($fullpath =~ m~(\w:)/(.*?)([^/]+)$~);


would output:
C:
TopDir/outer/inner/
file.fl


-----Original Message-----
From: Curtis Poe [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 3:39 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Regex help Please...


--- [EMAIL PROTECTED] wrote:
> I know this is not a good RegEx. Can I see some criticism and fine-tuning
of
> this RegEx that I came up with? 
> 
> Objective: To parse the path to drive, directory and file name.
> 
> Here is what I came up with.
> 
> #################################
> $fullpath = "C:/TopDir/outer/inner/file.fl";
> ($drive, $path, $file) =  ($fullpath =~
/(\w?):\/((?:\w+\/)*)(\w+\.\w+)$/);
> print("$drive\n $path\n $file");
> ###################################

Rex,

I think you'll be pleased with File::Basename.

    use strict;
    use File::Basename;

    my ( $filename, $dir ) = fileparse 'C:/temp/test.txt';
    my ( $drive ) = $dir =~ /^([^:]:)/;

    print "Filename:\t$filename\nDirectory:\t$dir\nDrive:\t$drive";

Output:

    Filename:       test.txt
    Directory:      C:/temp/
    Drive:  C:

Cheers,
Curtis "Ovid" Poe

=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to