in reply to How to build system calls using '=>'
I appreciate that you're just using "mkdir -p" as an example here... but for any passers by who are hunting for a way to make a path of directories they would be better following blue_cowdawg's advice in Re: "mkdir -p" equivalent? and using mkpath in File::Path
If they have a reason they can't use File::Path (even though it's a core module these days) they would be better using the built-in mkdir than shelling out to a system one.
and Three has dealt with some of the problems faced by Windows users in Re: Perl API that emulates mkdir -p on unix? (yes, for *Windows*) :o)use strict; use warnings; my $seperator = '/'; # Change this for a non-Unix compatible OS my @dirs = ("some/long/dir/path"); for my $path ( @dirs ) { my @path = split($seperator, $path); my $cat_path; for my $dir (@path) { $cat_path .= $dir; unless ( -d $cat_path ) { mkdir ( $cat_path ) || die "Can't mkdir '$cat_path': $!\n"; print "mkdir: created directory `$cat_path'\n"; } $cat_path .= $seperator; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to build system calls using '=>'
by Perl Mouse (Chaplain) on Dec 14, 2005 at 14:21 UTC | |
by serf (Chaplain) on Dec 14, 2005 at 15:45 UTC | |
by Perl Mouse (Chaplain) on Dec 14, 2005 at 16:40 UTC | |
by Anonymous Monk on Apr 17, 2009 at 16:34 UTC |
In Section
Seekers of Perl Wisdom