First, I want to say that I laughed my head off when I read your sig line (have you seen Running With Scissors?).
You need to be very careful with study. To the best of my knowledge, it's always been very buggy. In fact, in later versions of Perl (not sure about 5.6), successful matches against $_ can fail if you're using study, even if the string your matching against isn't what you studied. Apparently, the only way to get around this is to explicitly undef the studied string as soon as you are done with it (see Mastering Regular Expressions, second edition, page 289).
If you're willing to risk the problems with study, you should go ahead and benchmark it, but I wouldn't bother with it, personally.
Cheers,
Ovid | [reply] |
Hi Hot Pastrami,
study() (correct me if I'm wrong here guys) is only useful if you are going to search many keywords on the same string. Think of it as building an index of where all the a's and the b's, etc.. are located in the string so that if you need to see if 'airplane' is there, you can look really quickly (ok, so it doesn't do exactly that... but it's the same idea! :) ).
So if you are only going to look at a few keywords then don't bother with study, but if you are going to look at a few hundred keywords, then it might help alot more! (The exact cut off value depends on the length of the string, the length of the keywords, and the number of the keywords -- yes the length of the keywords effects the speed of a lookup, both ways).
Cheers,
Gryn | [reply] |
You maybe know this already, but in case you don't: if you
want to do some benchmarking, make sure you check out the
Benchmark module, which is part of the Perl standard distribution.
--ZZamboni
| [reply] |