note
Anonymous Monk
Thank you!
The result for the code:
<code>
use strict;
use Data::Dumper;
my %hash1 = (
key1 => 'relative_path',
key2 => {
key21 => 'another_relative_path',
key22 => '/an_absolute_path',
key23 => 'relative_path',
},
key3 => '',
key4 => 4
);
my @paths = ('key1', 'key2:key22', 'key2:key23');
for my $path (@paths) {
my @path = split(/:/, $path);
my $val = dive(\%hash1, @path);
warn $val;
}
sub dive {
my $r = shift;
$r = $r->{shift(@_)} while $r && @_;
return $r;
}
</code>
is:
<code>
relative_path at test2.pl line 20.
/an_absolute_path at test2.pl line 20.
relative_path at test2.pl line 20.
</code>
So I can get the values of interest to be checked, but how do I set them in the new %hash2?
1225365
1225369
8