in reply to Extracting from variables

If you want to grab each portion of the path, delimited by '/', you can do this (more on '/' later):

my $dir1 = 'c:/reports/temp1/temp2'; my $dir2 = 'c:/output'; my( @dirs ) = split /\//, $dir1; $dirs[0] = $dir2; foreach my $dir ( @dirs ) { $dir2 .= '/' . $dir; mkdir $dir2 or die $!; }

Note: For the sake of portability and simplicity, Perl allows you to separate directories with a '/' character, which is a whole lot easier to deal with than '\' characters. And you can do it that way on both a Windows system and a *nix system, from within a Perl script.


Dave