$ cat .bash_aliases alias pt='perltidy -i=2 -utf8 -b ' #### $ ./21.clone.pl 7.cw 2.scratch ... making directories abs to template is /home/bob/2.scripts/pages/2.scratch/template_stuff string abs from is /home/bob/2.scripts/pages/7.cw/template_stuff ------------- copying files child is /home/bob/2.scripts/pages/7.cw/template_stuff/Ð´Ð¸Ñ€ÐµÐºÑ‚Ð¾Ñ€Ð¸Ñ copy path is /home/bob/2.scripts/pages/3.scratch/template_stuff/директория /home/bob/2.scripts/pages/7.cw/template_stuff/Ð´Ð¸Ñ€ÐµÐºÑ‚Ð¾Ñ€Ð¸Ñ is neither file nor directory ... copy path is /home/bob/2.scripts/pages/2.scratch/template_stuff/ruscaptions We are now in is_dir create directory return is 1 this ^^^ should be a return for mkpath ... cross path is /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords ----------trying visit method $VAR1 = { '/home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/eugene/hs_ref_GRCh38.p12_chr20.fa' => 65455484, ... "/home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/\x{d0}\x{b8}\x{d0}\x{b7}\x{d0}\x{be}\x{d0}\x{b1}\x{d1}\x{80}\x{d0}\x{b0}\x{d0}\x{b6}\x{d0}\x{b5}\x{d0}\x{bd}\x{d0}\x{b8}\x{d0}\x{b5}" => undef, ... "/home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/\x{d0}\x{b7}\x{d0}\x{b0}\x{d1}\x{85}\x{d0}\x{b2}\x{d0}\x{b0}\x{d1}\x{82}" => undef, ... "/home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/\x{d0}\x{bf}\x{d0}\x{be}\x{d0}\x{b4}\x{d0}\x{bf}\x{d0}\x{b8}\x{d1}\x{81}\x{d0}\x{b8}" => undef, ... ----------------- $ #### $ cat 21.clone.pl #!/usr/bin/perl -w use 5.011; use utf8; use open qw/:std :utf8/; use Path::Tiny; use Encode; use open OUT => ':encoding(UTF-8)', ':std'; # 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. ###### ## enabling cyrillic ## decode argv and current ###### revision for crosswords...losing $pop in argv.... say "argv is @ARGV"; foreach (@ARGV) { say "before decode is $_"; $_ = decode( 'UTF-8', $_ ); say "after decode is $_"; } my ( $from, $to) = @ARGV; my $current = Path::Tiny->cwd; $current = decode( 'UTF-8', $current ); say "current is $current"; say "-------------"; say "making directories"; # define the paths within the target directory: my $ts = "template_stuff"; my $abs_to = path( $current, $to, $ts ); $abs_to->mkpath; say "abs to template is $abs_to"; # $from template directory: my $abs_from = path( $current, $from, $ts ); say "string abs from is $abs_from"; say "-------------"; say "copying files"; #### using iterator method to copy template stuff my $iter = $abs_from->iterator(); while ( my $child = $iter->() ) { say "child is $child"; my $base = $child->basename; $base = decode( 'UTF-8', $base ); ### added to handle cyrillic # adding the following line in hopes of shoestring tackle: #$child = decode( 'UTF-8', $child ); my $copy_path = path( $abs_to, $base ); say "copy path is $copy_path"; if ( $child->is_dir ) { say "We are now in is_dir"; my $return7 = $copy_path->mkpath; say "create directory return is $return7"; say "this ^^^ should be a return for mkpath"; } elsif ( $child->is_file ) { my $return8 = path($child)->copy($copy_path); say "copy file return is $return8"; }else { say "$child is neither file nor directory"; } } #### exploring more of Path::Tiny my $cross_path = path($abs_from, "crosswords"); say "cross path is $cross_path"; say "----------trying visit method"; my $sizes = $cross_path->visit( sub { my ( $path7, $state ) = @_; return if $path7->is_dir; $state->{$path7} = -s $path7; }, { recurse => 1 } ); use Data::Dumper; print Dumper $sizes; #say "sizes is $sizes"; say "-----------------"; $