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

Re^3: Template, sorting an array with only one member

by Mr. Muskrat (Canon)
on Oct 20, 2014 at 18:10 UTC ( [id://1104474]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Template, sorting an array with only one member
in thread Template, sorting an array with only one member

Container's one method is returning a single Object object instead of an array reference with a single Object object inside.

The fix is quite simple:

sub one { my $self = shift; my $filter = shift; return [ grep { $_->{'value'} == $filter } @{$self->{'objects'}} ]; }

Output:

container=Container=HASH(0x1cc2e10)
all:

Object=HASH(0x1cdf6b0) name is foo

Object=HASH(0x1cdf788) name is bar

one:

Object=HASH(0x1cdf6b0) name is foo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-26 00:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found