#!/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 created. $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); } } #### $ ./4.clone.pl 2.med 3.med 2.med ------------- making directories ------------- copying files matching is 5.unicode1.css copy failed for /home/bob/1.scripts/pages/2.med/template_stuff/5.unicode1.css to 1/5.unicode1.css: No such file or directory at ./4.clone.pl line 41. $