===== file: test.configtiny [dirs] dir_output_base=./ ===== file: test.yaml dirs: dir_output_base: ./ ===== testyc.pl (run as perl -wT testyc.pl ===== #!/usr/bin/perl -wT use strict; # ====================== use YAML::Tiny; my $yaml = YAML::Tiny->new; $yaml = YAML::Tiny->read( 'test.yaml' ); my $file1="testyc1.txt"; print "Printing to dir: " . $yaml->[0]->{dirs}->{dir_output_base}; print "\n"; print "Printing to file: " . $file1; print "\n"; # choose one of the following lines for tainted or untainted # my $ut = $yaml->[0]->{dirs}->{dir_output_base}; my $ut = $1 if ($yaml->[0]->{dirs}->{dir_output_base} =~ /(.*)/); # the above line untaints anything, just for testing purpose here. open (my $outfile1, '>', $ut . $file1); print $outfile1 "hello from testyc.pl\n"; close($outfile1); # ====================== use Config::Tiny; my $config=Config::Tiny->read('test.configtiny'); my $file2="testyc2.txt"; print "Printing to dir: " . $config->{dirs}->{dir_output_base}; print "\n"; print "Printing to file: " . $file2; print "\n"; open (my $outfile2, '>', $config->{dirs}->{dir_output_base} . $file2); print $outfile2 "hello from testyc.pl\n"; close($outfile2);