[Pdx-pm] mkdir -p ?

Roderick A. Anderson raanders at acm.org
Sun Aug 26 21:01:15 PDT 2007

Roderick A. Anderson wrote:
> Keith Lofstrom wrote:
>> The dirvish backup script (written in Perl) does a mkdir to make the
>> directory where new backups go.  One of the users makes many backups
>> per day, and would like to organize those into subtrees.   This
>> would be easy if Perl had the equivalent of "mkdir -p ARG" rather
>> than just "mkdir ARG". 
>> I can think of many ways to fake "mkdir -p" (recursive, system call,
>> etc.) but there is probably an elegant way to do it.  Suggestions?
> Well I loved all the other suggestions.  All _very_ perl but I had the 
> same need and just cheated since it was a Linux system and no need to 
> make it work on Windows.
> 	qx{ /bin/mkdir -p path/that/was/needed }
> Rod

WOW!  Who would have thunk one line could generate so much discussion.  :-)

You'll have to trust me that I did consider all the discussed points in 
the other replies to this post.

The code was not going to any other system.  The script generated the 
path information so the escaping of characters or other code injection 
possibilities are not going to happen.  It just whacked any "bad" 
characters in advanced.

I did capture the returned value.

On the other hand I can't remember seeing mkpath as part of the 
File::Path module.  Probably I was thinking "mkdir -p" not that I was 
making a path.  I'll revisit File::Path module.


More information about the Pdx-pm-list mailing list