Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Need help to fine tune perl script to make it faster( currently taking more than 30 minutes)

by space_monk (Chaplain)
on Nov 14, 2012 at 04:34 UTC ( #1003747=note: print w/replies, xml ) Need Help??


in reply to Need help to fine tune perl script to make it faster( currently taking more than 30 minutes)

Others have given you most of the answer, but it also looks as though you're pulling the record number out by some incredibly convoluted process. What is wrong with something like:
/Record(\d+):/ && do { $recnum = $1; s/$str1/$str2/g; s/$str3/$str4/g; .. }
This checks for matching lines and pulls the record number out at the same time...

Note that the regex in the above may not be quite right as your original seems to back up 6 characters from the ':', but the regex can be amended to do that too.

A Monk aims to give answers to those who have none, and to learn from those who know more.
  • Comment on Re: Need help to fine tune perl script to make it faster( currently taking more than 30 minutes)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003747]
help
Chatterbox?
[stevieb]: perldigious You should start by writing some unit tests. That'll ensure current functionality doesn't break with changes.
[choroba]: unit tests++
[choroba]: The only problem you can't solve by adding more tests is the problem of having too many tests.
[stevieb]: choroba Been there, done that :) Better too many than not enough though!
[stevieb]: I very often write a base set of unit tests before writing any code. It helps dictate the API, and ensures my earliest of ideas stay on track.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-07-21 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (335 votes). Check out past polls.