Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, I need a perl mkdir-like function that works recursively on absolute and relative paths for the windows platform (it seems mkdir should be able to do this????). any suggestions? thanks so much, Michael

Replies are listed 'Best First'.
Re: recursive mkdir
by boo_radley (Parson) on Oct 25, 2002 at 14:32 UTC

    try File::Path.

    use File::Path; eval { mkpath 'c:/foo/bar/' }; warn "problem making directory : $@" if $@; eval { mkpath '../baz/quux/' }; warn "problem making directory : $@" if $@;

Re: recursive mkdir
by sch (Pilgrim) on Oct 25, 2002 at 14:30 UTC

    Hi, have a look @ recursive mkdir which is asking a similar (if not the same) question.

    But today you took me walking, Through a land that we have lost,
    While our children sit at websites, With no access to the cost

      sch, thanks for the link. michael
Re: recursive mkdir
by broquaint (Abbot) on Oct 25, 2002 at 14:49 UTC
    Starved of a good SoPW on a Friday I have come up with
    use strict; use Cwd; use File::Spec; my($dir,$dest) = @ARGV; my $d = defined $dest ? $dest : cwd(); ## don't die incase intermediate dirs exist $d = File::Spec->catdir($d, $_) and not -d $d and mkdir($d) for File::Spec->splitdir($dir);
    Of course using the likes of mkpath from File::Path is probably a better idea.
    HTH

    _________
    broquaint