Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Below is proof of concept code: My question is what is correct syntax to replace print with mkdir (useFile::Path Module)? End goal is to create directories from an ASCII file where each line is the directory to make.

  • Example of line by line entries in file being read:
  • 000-ARCHITECTURAL-STRUCTURAL
  • 100-MECHANICAL
  • 101-Makeup_Air_Handlers-Cleanroom
  • 102-Recirc_Air_Handlers-Cleanroom
  • 103-Makeup_Air_Handlers-General
  • 104-General_Air_Handling_System
  • 105-Air_Condensing_Cooling_Heating_Coils
#!/usr/bin/perl -w <-- Not required on Windows, find -w arg??? # Perl v5.14.2 Last Edit GSR 2012-06-22 12:00 # # Create subroutine to make directories from ASCII file containing # a line of text without spaces representing the directories use strict; use warnings; use diagnostics; # use File::Path qw(make_path); <-- recommended by PerlMonks and works + use File::Path qw(make_path remove_tree); # Scaler string my $GSR_dir = "F:/sandbox/"; # Scaler string my $GSR_file = "UPN_List12.06.02.txt"; # append the scalers / strings my $GSR_file2read = join ('/',$GSR_dir, $GSR_file,); # Ok, lets go open(my $GSR_fh, "<", $GSR_file2read) or die "cannot open <, String: $!"; # this reads the content of the file handle (file) into the array vari +able # but a pointer to the file handle is at the end of the file so any # subsequent use of <$GSR_fh> yields null my @thefiles = <$GSR_fh>; # see if we have list in var # print @thefiles; <-- Works so we use that array # See if we have string in vars # print $GSR_dir; <-- Works # print $GSR_file; <-- Works # Using line below proved the module loaded and executed.... # make_path 'F:/sandbox/123_water'; # Line below creates directories in resident directory of program exec +ution make_path ( map {chomp; $_} @thefiles ); # Can join append string to the file I want made? close $GSR_fh;

In reply to Use Mkdir to create dir from list by GregorySRobinson

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (12)
    As of 2014-07-31 09:45 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (248 votes), past polls