cyber-guard has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks
I have this script to output me all the possible directory combinations from a path:
And as any perl wisdom seeker, I wonder if there is more elegant way to write this. I was messing around with map, but couldn't really get anything working...yet.
I have this script to output me all the possible directory combinations from a path:
my $a = "/aaaa/bbbb/cccc/dddd/index.html"; my ($clean_path) = $a =~ /(.*\/)/; my @dir_split = split /\//,$clean_path; my $stringer; foreach (@dir_split) { $stringer .= $_."/"; say $stringer; }
And as any perl wisdom seeker, I wonder if there is more elegant way to write this. I was messing around with map, but couldn't really get anything working...yet.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Alternative for a directory builder
by Eliya (Vicar) on Feb 22, 2011 at 18:50 UTC | |
by cyber-guard (Acolyte) on Feb 22, 2011 at 19:39 UTC | |
Re: Alternative for a directory builder
by ikegami (Patriarch) on Feb 22, 2011 at 19:31 UTC | |
Re: Alternative for a directory builder
by atcroft (Abbot) on Feb 22, 2011 at 18:40 UTC | |
by ikegami (Patriarch) on Feb 22, 2011 at 19:33 UTC | |
by cyber-guard (Acolyte) on Feb 22, 2011 at 19:41 UTC | |
Re: Alternative for a directory builder
by ikegami (Patriarch) on Feb 22, 2011 at 19:45 UTC | |
Re: Alternative for a directory builder
by Khen1950fx (Canon) on Feb 22, 2011 at 19:01 UTC |
Back to
Seekers of Perl Wisdom