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.
In reply to Re: how to open a data file via http
by hangon
in thread how to open a data file via http
by mwhiting
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |