in reply to Re: Perlish while loop
in thread Perlish while loop

ESPer, why did you go with

for (keys %filenames) { delete $filenames{$_} if $filename eq $_; }

instead of simply

delete $filenames{$filename};

and just not worry about the cases where the $filename wasn't one of the ones that you're interested in? keys has to build a list, then that has to be traversed, and each value compared. I could understand

if ( exists $filenames{$filename} ) { delete $filenames{$filename}; }

especially if there is a chance that %filenames is tied to something big and slow. Is there something that I overlooked?

- doug

Replies are listed 'Best First'.
Re^3: Perlish while loop
by dsheroh (Monsignor) on Jul 17, 2009 at 08:55 UTC
    Honestly? Because I was translating from the non-hash version above it and just copied the structure without thinking about it. Thanks for catching that!