in reply to how to open a data file via http
The http protocol does not directly support what you're trying to do. It's designed to return an entire file specified in an http request, not parts of a file. The easiest solution would be to slurp a copy of the file into a variable. Here are a couple of ways using LWP::Simple.
use LWP::Simple; # get file into variable my $data = get('http://www.jaywil.com/libsearch/SAMPLE.TXT'); # print all at once print $data; # or break up and print line by line # update: to keep blank lines at eof see comment by ikegami below @lines = split(/\n/, $data); for (@lines){ print "$_\n"; }
If for some reason you actually need to get the file one line at a time over http, you would need some help on the server side. If someone hasn't already written a module for this, you could write a cgi script that keeps state information and handles a few operations such as *open*, *read_line* and *close*. Basically you would be designing your own mini protocol to run over http.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to open a data file via http
by ikegami (Patriarch) on Feb 27, 2007 at 06:53 UTC | |
by pKai (Priest) on Feb 27, 2007 at 15:26 UTC | |
by ikegami (Patriarch) on Feb 27, 2007 at 16:39 UTC | |
by pKai (Priest) on Feb 27, 2007 at 17:31 UTC |