Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

RE: How DO those monks do it?

by runrig (Abbot)
on Oct 17, 2000 at 21:21 UTC ( #37193=note: print w/ replies, xml ) Need Help??


in reply to How DO those monks do it?

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 to you.


Comment on RE: How DO those monks do it?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://37193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (18)
As of 2014-12-18 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls