Skip to content

Instantly share code, notes, and snippets.

@nicomen
Created July 27, 2016 10:03
Show Gist options
  • Save nicomen/f7344f7c27715fcbccc00126d8837374 to your computer and use it in GitHub Desktop.
Save nicomen/f7344f7c27715fcbccc00126d8837374 to your computer and use it in GitHub Desktop.
#!/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