Thx haukex, I think I'm calling the mkdir method properly in this script so far. I'm getting alright partial results but want to cast the final solution in the idioms of Path::Tiny. Could I save myself the mkdir call by using the module better with the touchpath method?

I don't seem to know how to refer to the "children" I've created other than by "$_". First, output:

$ ./4.clone.pl 2.med 1.ert 2.med ------------- making directories ------------- copying files matching is 5.unicode1.css a is /home/bob/1.scripts/pages/2.med/template_stuff/5.unicode1.css b is 0/5.unicode1.css matching is utils1.pm a is /home/bob/1.scripts/pages/2.med/template_stuff/utils1.pm b is 0/utils1.pm ... matching is code1.tmpl a is /home/bob/1.scripts/pages/2.med/template_stuff/code1.tmpl b is 0/code1.tmpl ... ^^^zeroes here on the path for b, why? default is /home/bob/1.scripts/pages/2.med/template_stuff/5.unicode1.c +ss default is /home/bob/1.scripts/pages/2.med/template_stuff/utils1.pm default is /home/bob/1.scripts/pages/2.med/template_stuff/5.txt ... default is /home/bob/1.scripts/pages/2.med/template_stuff/footer_cente +r.txt default is /home/bob/1.scripts/pages/2.med/template_stuff/config1.pm default is /home/bob/1.scripts/pages/2.med/template_stuff/code1.tmpl $

What gives with the path for b having that o at the front? Source listing:

$ cat 4.clone.pl #!/usr/bin/perl -w use strict; use 5.010; use utf8; use open qw/:std :utf8/; use Path::Tiny; # This script clones the template directory in $1 to $2. # Some names need munging. # $from is a populated child directory; $to is child dir to be create +d. $pop is the folder with the data. my ( $from, $to, $pop ) = @ARGV; my $ts = "template_stuff"; my $current = path(".")->absolute; #say "current is $current"; say "-------------"; say "making directories"; # make root directory of clone: my $rd1 = path( $current, $to )->mkpath; # define the paths within the target directory: my $rd3 = path( $current, $to, $ts )->mkpath; # $from template directory: my $rd6 = path( $current, $from, $ts ); say "-------------"; say "copying files"; opendir my $eh, $rd6 or die "dead $!\n"; while ( defined( $_ = readdir($eh) ) ) { if (m/(txt|pm|css|tmpl|pl|sh)$/) { say "matching is $_"; $a = path( $rd6, $_ ); say "a is $a"; $b = path( $rd3, $_ ); say "b is $b"; #copy( $a, $b ); #path( $rd6, $_ )->copy($b); } } # for ( $dir->children ) { ... } for ( $rd6->children ) { say "default is $_"} #my $iter = $rd6->iterator; #while ( my $next = $iter->() ) { say "default is $_"} $

I'm looking for a way to loop through this file copy like a grown-up and be able to establish permissions on the files copied according to their endings following the usual conventions of what consituents an executable.


In reply to Re^2: shedding a bash wrapper and updating to Path::Tiny by Aldebaran
in thread shedding a bash wrapper and updating to Path::Tiny by Aldebaran

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, 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.