in reply to Re^4: Efficient regex matching with qr//; Can I do better?
in thread Efficient regex matching with qr//; Can I do better?

That is true. Does that also mean that it would be more efficient to write
foreach my $text_id (keys %hash2) { if ($hash2{$text_id} =~ $match) { ... } }
because then you copy nothing? If this is the case I was fooled by someone else (not in this thread) who said that using each was more efficient than using for/foreach...
Your second suggestion would, however, not work because there is no guarantee the strings are unique (in fact, I am certain they are not).
Thanks.

Replies are listed 'Best First'.
Re^6: Efficient regex matching with qr//; Can I do better?
by ysth (Canon) on Jul 14, 2008 at 05:49 UTC
    Try it and see?

    each() is more memory-efficient, but you aren't talking about millions of hash entries, so that's not likely to be a concern.