Re: How to improve speed of returning value from calling method on an array of objects?

On 1/6/06, Sai Tong <stong@xxxxxxxxxxxxxxxxxxx> wrote:
> I have an array of many objects and I want to call a method on
> each of these objects and the save the returned values into an array:

> my @return_values;
> foreach my $retrievedObject (@array_of_objects) {
> push (@return_values , $retrievedObject->method );
> }

Maybe you can use C<map>

my @return_values = map { $_->method } @array_of_objects;

But that's not going to be fast (as well as the for construction) if
the repeated calls of C<$_->method> aren't fast enough (for your