in reply to Re: Re: Fast sublist generation
in thread Fast sublist generation
This seems to speed things up for large hashes provided the matching list is a pretty small subset of the input.foreach my $key (sort grep(/$string/,keys %hash)) { if($key =~ /^$string(.*)$/) { blah; } if($key =~ /^(.*)$string$/) { blah; } }
Update: Since you are return()ing the first time you find a match, the sort() is doing more work than you need. You really need a min() function. There's a node that discussed various ways to implement a min().
|
|---|