Reading flat file server to server

Is there a way to  read a single flat file from CGIs on different servers?
I have tried open(DATA_FILE, http://www.domain.com/over_there/my_list.txt) || &die(cannot open!) ;  and it wont read, even with 0666.  
budginAsked:
Who is Participating?
 
prakashk021799Connect With a Mentor Commented:
No. The content of the web page is retrieved and saved in the variable $file. Perhaps I should have used a different name for the variable.

All you have to do is to process the data.
0
 
GnissmanCommented:
To retrieve a file from another server you should use the UserAgent (from libwww)

So your code would look like this:
-----------------------------------------------------------
# use libwww
use LWP::UserAgent;

# create new UserAgent object
$ua = LWP::UserAgent->new();

# create new HHTP-Request object
$request = HTTP::Request->new('GET','http://www.domain.com/over_there/my_list.txt');

# retrieve the Respone-object
$response = $ua->request($request);

# store content of my_list.txt to $document
$dokument = $response->content();
-----------------------------------------------------------

Still quite simple, isn't it? :o)

HTH,
Gniss
0
 
prakashk021799Commented:
How about simpler? :-)
Use the module appropriately named LWP::Simple.


use LWP::Simple;

$file = get('http://www.domain.com/over_there/my_list.txt')
            or die "can't get page.\n";


0
 
budginAuthor Commented:
I'm sorry, my knowledge, <em>at this time</em>, is fragmented. After that, do I proceed to: open(HANDLE, "$file") ? ......Thanks  
0
 
budginAuthor Commented:
I'm a happy camper.
0
All Courses

From novice to tech pro — start learning today.