$ cat utils2.pm package utils2; require Exporter; use utils1; use utf8; use open qw/:std :utf8/; use Data::Dumper; our @ISA = qw(Exporter); our @EXPORT = qw( archive1 ); sub archive1 { use warnings; use 5.011; use Path::Tiny; my $rvars = shift; my %vars = %$rvars; say Dumper $rvars; $vars{"grandfather"} = $vars{"init_dir"}->parent(); my $file1 = "1.manifest"; my $from = path( $vars{"grandfather"}, $file1 ); say "from is $from"; my @files = $from->lines_utf8( { chomp => 1 } ); say Dumper $rvars; say "files are @files"; my $tempdir = Path::Tiny->tempdir('backup_XXXXXX'); say "temp dir is $tempdir"; my $readme = $tempdir->child( 'grandmother', 'README.txt' )->touchpath; say "read me is $readme"; my $grand_dir = $readme->parent; chdir $grand_dir; foreach my $item (@files) { say "item is <<$item>>"; next if ($item eq ""); my $abs = path( $vars{"grandfather"}, $item ); say "abs is <$abs>"; if ( -d $abs ) { say "$abs is a directory"; } if ( -f $abs ) { say "$item is a plain file"; #syntax is from -> to my $return = path($abs)->copy( $grand_dir, $item ); if ( $item =~ m/\.(pl|sh)$/ ) { $return->chmod(0755); } say "return is $return"; } } my $b = $tempdir; return $b; } 1; $