Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Moose from ArrayRef[HashRef] to ArrayRef[Object]

by saintex (Scribe)
on Feb 23, 2011 at 17:06 UTC ( [id://889833]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Moose from ArrayRef[HashRef] to ArrayRef[Object]
in thread Moose from ArrayRef[HashRef] to ArrayRef[Object]

This is an horrible solution, because of duplicate attributes:

YAML file:
tmpPages: - Page: URL: http://www.perlmonks.org/ - Page: URL: http://www.perl.org/
Objects container:
package PagesGenerator; our $VERSION=0.01; use Moose; with 'MooseX::SimpleConfig'; use Page; has 'tmpPages'=>( is=>'rw', isa=>'ArrayRef[HashRef]', default => sub { [ ] }, ); has 'pages'=>( is=>'rw', isa=>'ArrayRef[Page]', default => sub { [ ] }, ); sub BUILD{ my $self=shift; @{$self->pages}= map {new Page(URL=>$$_{Page}{URL});} @{$self->tmp +Pages}; for ( @{ $self->pages } ) { print $_->URL; print "\n"; } }


Any other idea?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found