Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: OO search in objects

by Happy-the-monk (Abbot)
on Aug 14, 2013 at 12:09 UTC ( #1049423=note: print w/ replies, xml ) Need Help??


in reply to OO search in objects

I wonder if there's a better way of doing it?

It depends... Assuming there are no duplicate names, I would create a hash once populated with the names as keys and the object refs as values.

my %objects_by_name; for (@obj_fw) { $objects_by_name{$_->name} = $_ }

or even better right when the objects are being created/given names.

From then on you get the objects by name from $objects_by_name{$name}

Cheers, Sören

Créateur des bugs mobiles - let loose once, run everywhere.
(hooked on the Perl Programming language)


Comment on Re: OO search in objects
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (14)
As of 2015-07-28 18:24 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 (258 votes), past polls