|
Posted by Bjoern Hoehrmann on May 23, 2008, 6:55 am
Please log in for more thread options
* Leif Wessman wrote in comp.lang.perl.misc:
>I'm parsing a text-file, line by line. But it is almost 100 MB. Is it
>possible to use a buffer instead of loading the complete text file
>into memory?
>
>This is the code I'm using today:
>
>my $url = "http://datafeed.com/somefile.txt";
>my $req = new HTTP::Request GET => $url;
>my $ua = new LWP::UserAgent;
>my $res = $ua->request($req);
The second parameter to the request method takes a content callback,
you can also specify the special field :content_cb, see the notes in
`perldoc LWP::UserAgent` and see `perldoc lwpcook` for an example.
--
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
|