Link to home
Start Free TrialLog in
Avatar of ItsMe
ItsMe

asked on

how to read a file which is lying on any server ?

Hi ! How can I read a file which is not lying on my server ? The user types in the url and I want to open this file and save it in an array of lines.

How to do this  (code) ?

regards
ItsMe
Avatar of ItsMe
ItsMe

ASKER

ps: I want to do this with perl.
you will need to use a sockets library for Perl - which will let you make TCP/IP socket connections to other servers, the use these connections to retrieve files from the other machines.

The protocol to be used depends on the URL - i.e. http or ftp
Avatar of ItsMe

ASKER

it will be always a link like http://www.anyserver.de/any.txt
Isn't it easyer to manage that ? I just want to read the file. I found a code which works (but there are strange ascii's in it):

use LWP::Simple;
$rc = getprint('http://www.anyserver.de/whatever.txt');
print status_message($rc);

PS: I'm new in Perl and don't know how to manage this problem. It would be cool to have some source.

regards
ItsMe
Avatar of ozo
What do you mean there are strange ascii's in it?
Avatar of ItsMe

ASKER

If start the cgi my browser asks me for saving the file. If I saveit it includes I think line breaks at the end of each file. how can I read the file in an array of lines ?
perhaps by splitting with <cr><lf> as divider ? how do I write this in perl ?

@lines = split.....

regards
ItsMe

PS: Can you explain what the code above does ? (getprint ...)
ASKER CERTIFIED SOLUTION
Avatar of maxkir
maxkir
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial