Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Enumerating all attributes of a Moo object

by frozenwithjoy (Curate)
on Jul 08, 2013 at 22:37 UTC ( #1043202=note: print w/ replies, xml ) Need Help??


in reply to Enumerating all attributes of a Moo object

Moo(se) objects are essentially hashrefs, so you can just do this:

print "$_\n" for keys %{$moo_object};


Comment on Re: Enumerating all attributes of a Moo object
Download Code
Replies are listed 'Best First'.
Re^2: Enumerating all attributes of a Moo object
by zwon (Monsignor) on Jul 09, 2013 at 16:51 UTC
    Note, that this will not show attributes that are not set:
    use 5.010; use strict; use warnings; { package Foo; use Moose; has bar => ( is => 'rw' ); has baz => ( is => 'rw' ); } my $foo = Foo->new( bar => 1 ); say join "\n", keys %$foo; __END__ bar

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043202]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2015-07-28 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls