in reply to Re: shedding a bash wrapper and updating to Path::Tiny
in thread shedding a bash wrapper and updating to Path::Tiny

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:

$ ./ 1.ert ------------- making directories ------------- copying files matching is 5.unicode1.css a is /home/bob/1.scripts/pages/ b is 0/5.unicode1.css matching is a is /home/bob/1.scripts/pages/ b is 0/ ... matching is code1.tmpl a is /home/bob/1.scripts/pages/ b is 0/code1.tmpl ... ^^^zeroes here on the path for b, why? default is /home/bob/1.scripts/pages/ +ss default is /home/bob/1.scripts/pages/ default is /home/bob/1.scripts/pages/ ... default is /home/bob/1.scripts/pages/ +r.txt default is /home/bob/1.scripts/pages/ default is /home/bob/1.scripts/pages/ $

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

$ cat #!/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.