Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: About $/

by FloydATC (Deacon)
on May 24, 2013 at 10:52 UTC ( [id://1035109]=note: print w/replies, xml ) Need Help??


in reply to Re: About $/
in thread About $/

If all else fails, use sysread() to implement your own read buffering and split the incoming data on the fly.

open(my $fh, '/my/huge/file') || die $!; binmode $fh; my $separator = "\r*\n|\t|whatever"; my $buffer = ''; my $block; while (sysread($fh, $block, 4096)) { $buffer .= $block; while ($buffer =~ /$separator/) { process_line($`.$&); # prematch + match $buffer = $'; # postmatch } } print "--\n"; process_line($buffer) if $buffer; # remainder, if any. close $fh;

This gives you full control over how to split the data into lines, without significant memory overhead.

-- Time flies when you don't know what you're doing

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found