I STILL constantly refer to 'perldoc -f <perlfunction>'and find it invaluable. Just yesterday I had to look up the
arguments for index() and their order. It was a happy day when I found out about the '-f' option and didn't have to search through 'perlfunc' anymore. I wish you could do that with all the perl modules too.
At the more general 'how do I do something' sort of level, I've found the perlfaqs very handy. When I needed to fork(), there were examples in perlipc. Since I've scanned all the perldocs, I have a vague idea of most everything in there, and if I can't find it in there, then I'll go to a book (I have the Cookbook, and at my latest work we have all the other books also). I just wish I had all the animal books to refer to when I was just learning perl, all there was was one crappy book at work, so the perldocs were usually more helpful. (Why didn't I go get'em myself? I dunno...).
I try to write code in small bits that can be tested separately whenever possible. I hate it when someone modifies a large application and breaks it when a small test
case could have avoided disaster (which is becoming my latest justified pet peeve). I'll benchmark if I think its worthwhile and/or if I have time and/or if I'm just curious enough. Going back to that 'index' function, I was wondering
how much faster using 'index' was versus a regex, because a
co-worker wrote a split using a regex, and index() could have been used instead. It was something like:
my ($str1, $str2, $str3, $str4) = /(.*)<tag1>(.*)<tag2>(.*)<tag3>(.*)/;
I was fairly certain that using index would be faster, but not sure by how much. Even the regex could have been sped up by adding '?' after the '*' in all but the last group. For the curious, on 500 iterations, using index benchmarked for me at ~0.1 seconds, the bad regex at ~6 seconds, the slightly better regex at ~3 seconds. So in 500 executions of this script, we can save 5-6 seconds, which may or may not be worthwhile in the big picture, but
at least my curiosity is satisfied.
Oh well, I don't know if that helps any or not, but Good Luck
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||