For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > February 2006 > Is there a GNU-like "mkdir -p" method in Perl?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Is there a GNU-like "mkdir -p" method in Perl?
Sean

2006-02-28, 7:56 am

Hi all. I wrote a script to retrieve and parse some XML and it writes a
log file (and the aquired XML) to disk whem complete. Because I need to
share this with others, I included the ability to pass an optional PATH
argument to specify where you want the logs written. However, I have
not been able to find a simple way to create the parent directory AND
all subdirectories if they don't already exist... I realize I could cut
up the path and make each directory as I dig down, but it seems like
there would have to be a better way!

Am I missing something obvious, or do I have to make each sub directory
one at a time?

-Sean

Marcel

2006-02-28, 6:57 pm

Hi Sean

You could use following module:

use File::Path;
mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711);

Marcel

Sean

2006-02-28, 6:57 pm

Very !

Thanks Marcel.

-Sean

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com