--- [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]