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
ItsMeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ItsMeAuthor Commented:
ps: I want to do this with perl.
0
shiversCommented:
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
0
ItsMeAuthor Commented:
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
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

ozoCommented:
What do you mean there are strange ascii's in it?
0
ItsMeAuthor Commented:
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 ...)
0
maxkirCommented:
use LWP::Simple;

# Get file content
$content = get('http://www.anyserver.de/whatever.txt');

# split content
@lines = split(/\n/, $content);

getprint gets and prints file content.

regards,
KIR
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.