Skip to content

Instantly share code, notes, and snippets.

@shelling
Created July 10, 2012 06:01
Show Gist options
  • Select an option

  • Save shelling/3081453 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/3081453 to your computer and use it in GitHub Desktop.
prevent Data::SPath invoke methods on an object
#!/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