Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Override CORE::mkdir

by larryk (Friar)
on Feb 18, 2002 at 21:44 UTC ( #146259=snippet: print w/replies, xml ) Need Help??

Having read the discussion at recursive mkdir I decided to post this. I don't know who wrote it - it may have been me as it looks like code I could have written but I don't recall :-S

It exports mkdir which will create all nonexistent directories in the path provided.

package Mkdir;

use base qw(Exporter);
use strict;
use subs 'mkdir';
use warnings;

our @EXPORT = qw(mkdir);

sub mkdir {
    my $path = shift;
    my $mode = shift || '0777';
    my $d = '';
    for (split/[\\\/]/,$path) {
        $d .= $_.'/';
        -d $d || CORE::mkdir($d,$mode) || return




=head1 NAME - override CORE::mkdir with "complete" version.


    use strict;
    use warnings;
    use Mkdir;

Replies are listed 'Best First'.
Re: Override CORE::mkdir
by Kanji (Parson) on Feb 18, 2002 at 21:54 UTC

    You might want to check out File::Path's mkpath function, which provides similar functionality and has the added bonus of being a core module ... so nothing extra to install. :)

    # The "mkpath" function provides a convenient way to create # directories, even if your "mkdir" kernel call won't create # more than one level of directory at a time. mkpath(['/create/all/of/these', '/and/these/too'], 0, 0755);


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://146259]
[LanX]: it's pretty ironic if you know the character
choroba likes the movie
[choroba]: Lady_Aleena Do you really need to say "WorldBuilder" after having said "WorldBuilding"?
[LanX]: have to watch it again :)
[Lady_Aleena]: choroba, the tables in that group of modules is from the World Builder's Guidebook, so I thought it best to add the name of the book to the name of the module.
[choroba]: oh, I see
[Lady_Aleena]: There is the RolePlaying:: WorldBuilding:: WorldBuildersGuide book suite and the RolePlaying:: WorldBuilding:: HighLevelCampaigns suite.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-05-24 22:25 GMT
Find Nodes?
    Voting Booth?