Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create directory?

Status
Not open for further replies.

mooniron

Programmer
Dec 15, 2002
26
TR
Could anyone tell me how to create directory in Perl. Thanks
 
It's probably safer to do this:

use File::path;
mkpath($path);

In the case that you are trying to create a directory, where a previous directory doesn't exist.

i.e. You want to create: /documents/tests/drivers/linux/kernel

and directory /documents/tests/drivers doesn't exist....it wont be able to create the full directory using mkdir.

mkpath() will create all the previous non-created directories supplied in the path variable.

 
What about the situation where the exact path already exists, so it shouldn't create anything? How would mkpath handle that?

Basically I'm looking to for the same functionality as mkdir -p in a shell script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top