monsieur_champs has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks
I was building up a little regexp-intensive program and had a feeling that maybe I should tell perl to study something in the code. I wasn't able to remember when study() is usefull, and turned back to the old'n'good perl documentation. From perldoc -f study, I figured out this (my bold print, to stress my point):
study SCALAR
study Takes extra time to study SCALAR ($_ if unspecified) in anticipation of doing many pattern matches on the string before it is next modified. This may or may not save time, depending on the nature and number of patterns you are searching on, and on the distribution of character frequencies in the string to be searched (...)
This makes me think: is there any easy, newbie-proof criteria to decide when to use study? Or, in other words: is there any simple way to decide if I need or not to study a scalar before doing pattern matching?
One could, of course, stop programming, hunt down some samples from his/her expected input data, and spend a whole day benchmarking things to decide on his/her on experience. But this is time-consuming and requires some knowledge not always available for our less-skilled brothers. For this cases, even a poor criteria is better than to stop the fork for a long time period to (human) study and off-toppic knowledge aquisition.
Maybe together the mighty and wise Monks from this monastery could provide all the community with something easy to use and precise enough to satisfy the needs of our little brothers, at least until they have the necessary skills to do it on his/her own.
Thank you all for the wisdom advices and considerations on this toppic.
Update:Oh, I read Why study SCALAR?, and need to stress that I'm not asking about what study() does, but when to use it and much more important how to decide about the moment to use this powerfull resource.
"In few words, translating PerlMonks documentation and best articles to other languages is like building a bridge to join other Perl communities into PerlMonks family. This makes the family bigger, the knowledge greather, the parties better and the life easier." -- monsieur_champs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help on decide when study
by davido (Cardinal) on Nov 13, 2003 at 19:04 UTC | |
by monsieur_champs (Curate) on Nov 13, 2003 at 19:23 UTC | |
by davido (Cardinal) on Nov 13, 2003 at 19:35 UTC | |
by vacant (Pilgrim) on Nov 13, 2003 at 23:06 UTC | |
|
Re: Help on decide when study
by sauoq (Abbot) on Nov 13, 2003 at 19:46 UTC |