in reply to Re^4: redacting from config hash
in thread redacting from config hash

I just don't see where I'm not correctly imitating the syntax shown on Config::Tiny

Part way through you've stopped using a hashref and started using a hash. Just stick with the hashref. eg:

my $Config = Config::Tiny->new; $Config = Config::Tiny->read( $ini_path , 'utf8' ); say Dumper $Config; my $domain = $Config->{$sub_hash}->{'domain'}; my $username = $Config->{$sub_hash}->{'username'}; my $password = $Config->{$sub_hash}->{'password'}; my $port = $Config->{$sub_hash}->{'port'};

HTH.

Replies are listed 'Best First'.
Re^6: redacting from config hash
by Aldebaran (Curate) on Aug 06, 2018 at 21:39 UTC

    thx hippo, your code as posted worked:

    my $domain = $Config->{$sub_hash}->{'domain'}; my $username = $Config->{$sub_hash}->{'username'}; my $password = $Config->{$sub_hash}->{'password'}; my $port = $Config->{$sub_hash}->{'port'};

    but I was curious whether it would still work without the second arrows, and it does:

    sub get_tiny { use 5.011; use warnings; use Net::SFTP::Foreign; use Config::Tiny; use Data::Dumper; my $ini_path = qw( /home/bob/Documents/html_template_data/3.values.i +ni ); say "ini path is $ini_path"; my $sub_hash = "my_sftp"; my $Config = Config::Tiny->new; $Config = Config::Tiny->read( $ini_path, 'utf8' ); say Dumper $Config; # -> is optional between brackets my $domain = $Config->{$sub_hash}{'domain'}; my $username = $Config->{$sub_hash}{'username'}; my $password = $Config->{$sub_hash}{'password'}; my $port = $Config->{$sub_hash}{'port'}; #dial up the server say "values are $domain $username $password $port"; my $sftp = Net::SFTP::Foreign->new( $domain, user => $username, port => $port, password => $password ) or die "Can't connect: $!\n"; return $sftp; }

    Thx for your comment.