You might want to look at File::Spec, File::Path, and File::Copy. File::Spec is great for performing portable directory and filename operations (you don't have to remember which way the slashes should go). File::Path makes it very easy to create directory trees without having to specifically create all of the intermediate directories. File::Copy is used to copy or move files. As with any function call, you should verify it worked by either performing an independent test or by checking the return value.

For example:
use strict; use warnings; use File::Path; use File::Copy; use File::Spec; # Assemble a new dir name and create it my $dirpath = File::Spec->catdir( 'C:', 'dir1', 'dir2' ); mkpath( $dirpath ); # make sure the dir we tried to create exists, using -d (one option) my $install_error = 0; unless( -d $dirpath ) { $install_error = 1; } # (stuff if mkpath failed) my $pathfile = File::Spec->catfile( $dirpath, 'myfile.txt' ); my $copy_status = copy( 'myfile.txt', $pathfile ); if( $copy_status == 1 ) { print " copied myfile.txt to $dirpath\n"; } else { print " *** Error copying file: $!\n"; }
HTH

In reply to Re: mkdir on Windows 98 by bobf
in thread mkdir on Windows 98 by shn4002

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.