Created
July 10, 2012 06:01
-
-
Save shelling/3081453 to your computer and use it in GitHub Desktop.
prevent Data::SPath invoke methods on an object
This file contains hidden or 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/env perl | |
| use Modern::Perl; | |
| use Data::SPath spath => {}; | |
| use Data::Dumper; | |
| { | |
| package Hello; | |
| 1; | |
| } | |
| my $config = { | |
| hello => { | |
| world => { | |
| foo => "bar", | |
| } | |
| }, | |
| array => [ | |
| "first", | |
| "second", | |
| "third", | |
| { | |
| four => "five", | |
| }, | |
| ], | |
| }; | |
| bless $config, "Hello"; | |
| say spath({%$config}, "/hello/world")->{foo}; | |
| say spath({%$config}, "/hello/world/foo"); | |
| say spath({%$config}, "/array/3/four"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment