Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Help needed in reading a very large file line by line

by trizen (Hermit)
on Feb 28, 2012 at 15:06 UTC ( #956682=note: print w/ replies, xml ) Need Help??


in reply to Help needed in reading a very large file line by line

For very long lines, you can try something like this:

open my $fh, '<', $filename; my $line = ''; my $track = 0; my $max_line_length = 1024; # or whatever while (defined(my $char = getc $fh)) { $line .= $char; if (++$track == $max_line_length or $char eq "\n") { print $line; $line = ''; $track = 0; } } close $fh;


Comment on Re: Help needed in reading a very large file line by line
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2015-07-31 08:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls