Jump to content

problem in downloading a file using perl

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Rinku27

Rinku27

    Newbie

  • Members
  • Pip
  • 1 posts
Hi, i need to download a file using perl from a website. The link is the complete file address. Earlier i was able to do it using LWA as the file content could be viewed in the browser itself but now when i open the link in my internet browser its asking me to save the file so not showing the content of the file there itself. Could you please tell me how to handle it.
Thanks!

Edited by Rinku27, 18 July 2010 - 04:48 AM.
mistake in spelling


#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Install File::Remote from CPAN and it's straightforward from there:
#!/usr/bin/env perl
use File::Remote qw(:replace); # special :replace tag

# read from a remote file, display or download
open(REMOTE, "host:/path/to/remote/file") or die $!;
print while (< REMOTE >);
close(REMOTE);

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.