Created
July 27, 2016 10:03
-
-
Save nicomen/f7344f7c27715fcbccc00126d8837374 to your computer and use it in GitHub Desktop.
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/perl | |
use Data::Dumper; | |
local $Data::Dumper::Indent = 0; | |
package A; | |
use Moo; | |
has a => (is => "ro"); | |
has b => (is => "ro", lazy => 1, default => sub { shift->a + 1 }); | |
package main; | |
my $a = A->new( a => 1 ); | |
print Dumper({%$a}); | |
print Dumper([ | |
map { $_ => $a->$_; } $a->meta->get_attribute_list | |
])'; | |
# $VAR1 = {'a' => 1}; | |
# $VAR1 = ['b',2,'a',1]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment