in reply to How to find code written by smart people
System calls should make you a little nervous. It seems from the context of your post that you chose a system call because Perl's mkdir doesn't do what mkdir -p does on a Unix system. Here's a more-Perlish version that will work on most platforms (not just Unix):
#!/usr/bin/perl use strict; use warnings; use File::Spec::Functions qw(splitpath catdir rel2abs); # mkdir -p emulator, call with this.pl /path/to/create my $path = rel2abs(shift @ARGV); my $place = ''; foreach my $dir ( splitpath($path) ) { $place = catdir($place, $dir); (-d $place) || (mkdir $place, 0755) or die "Problem making $place: + $!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to find code written by smart people
by Hue-Bond (Priest) on Aug 25, 2006 at 17:16 UTC | |
by radiantmatrix (Parson) on Aug 25, 2006 at 19:46 UTC |