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


In reply to Help on decide when study by monsieur_champs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.