Created
July 20, 2014 10:04
-
-
Save andrewsolomon/572230a21bd4d43482c7 to your computer and use it in GitHub Desktop.
Data::Rmap - Example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Data::Rmap ':all'; | |
my $rh_config = { | |
convoluted => [ | |
'configuration', | |
'data', | |
'containing', | |
{ | |
username => 'and', | |
password => 'secret1' | |
} | |
], | |
password => 'secret2' | |
}; | |
my $data = rmap_to { | |
foreach my $key (keys(%$_)) { | |
if ($key eq 'password') { | |
$_->{password} = '*** CENSORED ***'; | |
} | |
} | |
} HASH, $rh_config; | |
print Dumper $rh_config; | |
=head2 The output | |
$VAR1 = { | |
'password' => '*** CENSORED ***', | |
'convoluted' => [ | |
'configuration', | |
'data', | |
'containing', | |
{ | |
'password' => '*** CENSORED ***', | |
'username' => 'and' | |
} | |
] | |
}; | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment