IIRC, technically, the for() would take more time but only noticeable with exceptionally large arrays. I seem to recall something about for() copying an array before iterating. Other than that, it's pretty much the same. You could use the benchmarking module (use Bench, I think, but check the Camel book), but I imagine the difference is no more than a tick or two.
Stylistically, however, I would recommend grep: @match = grep (int($filter) & int($image_data{$_}[2])) == $filter, @image_list; Keary Suska Esoteritech, Inc. "Leveraging Open Source for a better Internet" > From: Richard Smith <[EMAIL PROTECTED]> > Date: Mon, 19 Nov 2001 23:33:32 +0000 (GMT) > To: [EMAIL PROTECTED] > Subject: [MacPerl] Which is faster?... > > Hi All, > > I have too version of a routine that iterates through > about 140 elements of an array. I am trying to make > the script as efficient as possible (obviously), and I > have 2 versions of a routine that does a bitwise > comparison to match a filter. Can anyone tell me just > by looking which is likely to be fater? My guess is > the map version: > > 1. loop version: > > for (@image_list) { > ( int( $filter ) & int( $image_data{$_}[2] ) ) == > $filter and push @match, $_; > } > > 2. Map version: > > @match = map { ( int( $filter ) & int( > $image_data{$_}[2] ) ) == $filter and $_ or () } > @image_list; > > Any thoughts much appreciated. > > BTW, can anyone tell me why saying 'use integer' kills > the operation of 'localtime'? > > TIA, > > Richard > > > __________________________________________________ > Do You Yahoo!? > Everything you'll ever need on one web page from News and Sport to Email and > Music Charts > http://uk.my.yahoo.com >