CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Parsing extremely long lines

 



nfw
New User

Oct 6, 2011, 11:44 AM

Post #1 of 2 (939 views)
Parsing extremely long lines Can't Post

So I have a file, which consists of multiple very long lines, so long that I don't want to read the entire line for memory concerns. And for each line, I want to count the number of some special character, let's call it X

So a line could be:

....................X........blahlahblah....X...........X......., repeat 1 billion times.

So I have come up with 2 options:

1) pre process the lines and break them up into more manageable chunks. Then process line by line.

2) read a single character at time, do what's need when X is encountered, and go to the next character.

Which one is more efficient? Is there a better way?


(This post was edited by nfw on Oct 6, 2011, 11:46 AM)


Zhris
Enthusiast

Oct 6, 2011, 1:09 PM

Post #2 of 2 (933 views)
Re: [nfw] Parsing extremely long lines [In reply to] Can't Post

Have a look at Tie::File (http://search.cpan.org/~mjd/Tie-File-0.96/lib/Tie/File.pm), i've had very good experiences in using this module to process huge files.

Chris

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives