On Tuesday, August 20, 2002, at 09:00 , FlashGuy wrote:
> How can I retrieve the directory path and split the results into separate
> variables based on the "\"
>
> Example:
>
> d:\temp\test\files>
I would recommend the File::Basename approach, or you could
go with say:
#!/usr/bin/perl -w
use strict;
my $string = 'd:\temp\test\files>';
#
# remove the '>' at the end
#
$string =~ s/>//;
my @list = split(/\\/,$string);
print "$_ \n" for @list;
# to do that with the File::Basename
use File::Basename;
#
# remember to tell it what type of file systems...
fileparse_set_fstype("MSWin32");
my $t_dir = dirname($string);
my $file = basename($string, "\>");
my ($drive, $dir) = split(/:/, $t_dir);
$drive = $drive . ":";
print "we have $drive with <$dir> and <$file>\n";
my @otherList;
while ($dir ne '\\' ) {
my $tmp_d = basename($dir);
unshift(@otherList, $tmp_d );
$dir = dirname($dir);
}
print "the otherList has: $_\n" for @otherList;
HTH...
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]