Skip to content

Instantly share code, notes, and snippets.

@masaki
Created February 11, 2009 13:17
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 masaki/62002 to your computer and use it in GitHub Desktop.
Save masaki/62002 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use Data::OpenStruct::Deep;
my %hash = (
foo => 1,
bar => {
baz => 2,
},
);
my $struct = Data::OpenStruct::Deep->new(%hash);
print $struct->foo; #=> 1
print $struct->bar; #=> { baz => 2 }
print $struct->bar->baz; #=> 2
$struct = Data::OpenStruct::Deep->new;
$struct->foo->bar->baz->quux('deeply');
print $struct->foo->bar; #=> { baz => { quux => "deeply" } }
print $struct->foo->bar->baz->quux; #=> "deeply"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment