#!/usr/bin/perl -w use strict; use 5.010; use lib "template_stuff"; use utils1; use utils2; use utf8; use open qw/:std :utf8/; use Path::Tiny; my $current = Path::Tiny->cwd; say "current is $current"; my $return = redact("config2"); __END__ current is /home/bob/1.scripts/pages/1.qy temp dir is /tmp/backup_DEtSio scratch_file is /tmp/backup_DEtSio/batch_01/1.manifest.txt parent is /tmp/backup_DEtSio/batch_01 /tmp/backup_DEtSio $VAR1 = { 'my_sftp' => { 'username' => '', 'password' => '', 'domain' => '' }, 'my_github' => { 'password' => '', 'email' => '' } }; #### package utils2; require Exporter; use utils1; our @ISA = qw(Exporter); our @EXPORT = qw( redact); sub redact{ use strict; use warnings; use 5.010; use Path::Tiny; my $file = shift; #use $file; resulted in error use config2; my $sub_hash = "my_github"; my $email = $config{$sub_hash}->{'email'}; my $password = $config{$sub_hash}->{'password'}; my $tempdir = Path::Tiny->tempdir('backup_XXXXXX'); say "temp dir is $tempdir"; my $scratch_file = $tempdir->child('batch_01', '1.manifest.txt')->touchpath; say "scratch_file is $scratch_file"; my $parent = $scratch_file->parent; say "parent is $parent"; chdir $tempdir unless $tempdir->subsumes(Path::Tiny->cwd); system("pwd"); use Data::Dumper; print Dumper \%config; my $b = "dummy"; return $b; } 1;