Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Created July 20, 2014 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewsolomon/572230a21bd4d43482c7 to your computer and use it in GitHub Desktop.
Save andrewsolomon/572230a21bd4d43482c7 to your computer and use it in GitHub Desktop.
Data::Rmap - Example 1
#!/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