In unix there is a -p tag for the mkdir command. Is there a similar tag in Perl?

Recommended Answers

All 3 Replies

I don't think so, but it's real easy to shell to the prompt, and mkdir -p that way, such as:

system "mkdir -p whatever";

or you can just use ticks `mkdir -p whatever`; Hope this helps.

mkpath (part of the standard perl modules) does what you want:

use File::Path;
mkpath "foo/bar/"; #will create foo before bar if needed :)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.