Skip to content

Instantly share code, notes, and snippets.

@kamipo
Forked from hirafoo/gist:337522
Created March 19, 2010 14:26
Show Gist options
  • Save kamipo/337545 to your computer and use it in GitHub Desktop.
Save kamipo/337545 to your computer and use it in GitHub Desktop.
use strict;
use Data::Dumper;
sub foo {
my ( $a_ref, $key, $value ) = @_;
eval join('->', '$a_ref', map "{$_}", split /\./, $key) . ' = $value';
return $a_ref;
}
my $ref = {
foo => {
bar => {
baz => 1,
},
},
};
$ref = foo( $ref, 'foo.bar.baz', 100 );
warn Dumper $ref;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment