At 12:00 PM 8/20/02 -0400, FlashGuy wrote:

>Hi,
>
>How can I retrieve the directory path and split the results into 
>separate variables based on the "\"
>
>Example:
>
>d:\temp\test\files>
>
>Split:
>
>var1: d:
>var2: temp
>var3: test
>var4: files

Use File::Spec, which is also portable.  (Since I ran this on Unix, I 
had to fool it into thinking it was Windows to work with your example.)

$ cat foo
#!/usr/bin/perl -wl
use strict;
BEGIN { $^O = "MSWin32" }         # You won't need this
use File::Spec;
my $path = "d:\\temp\\test\\files";
my @dirs = File::Spec->splitdir($path);
print join " * " => @dirs;

$ ./foo
d: * temp * test * files

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/


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

Reply via email to