Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by roboticus (Canon)
on Nov 14, 2012 at 02:55 UTC ( #1003735=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)

anujajoseph:

I'd suggest not shelling out to sed to print a line. Instead, read the file into an array and print the appropriate line. That would be better than rescanning the file over and over. Or build an array of lines to print, then after the while loop, scan the file once, printing each line in your array.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


Comment on Re: Need help to fine tune perl script to make it faster( currently taking more than 30 minutes)
Re^2: Need help to fine tune perl script to make it faster( currently taking more than 30 minutes)
by anujajoseph (Novice) on Nov 14, 2012 at 03:08 UTC
    thanks for your suggestion , but the concern is since the source file is huge wont it cause memory issues if i open the file for reading the rows?

      anujajoseph:

      If the source file is too large to fit into memory, then the second suggestion might be better. But since computers tend to have so much RAM nowadays, most files will fit into memory.

      Update: On rereading the thread, I realize that in my first post I left out a word in the second suggestion. It should be an array of line numbers.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-07-12 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (238 votes), past polls