Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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:
  • 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

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, 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
  • 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (8)
    As of 2018-06-20 08:32 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (116 votes). Check out past polls.