File: get-file

package info (click to toggle)
libwww-perl 6.78-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,008 kB
  • sloc: perl: 4,148; makefile: 10; sh: 6
file content (23 lines) | stat: -rw-r--r-- 465 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl

use strict;
use warnings;

use LWP::UserAgent ();

my $file = shift || "";
my $to = $file;
$to =~ s|.*/||;  # only basename
$to = "index.html" unless length $to;


my $ua = LWP::UserAgent->new;
#$ua->agent("get-file/0.1");
#$ua->from('aas@sn.no');

my $res = $ua->request(HTTP::Request->new("GET", "http://localhost:8080/$file"), "$to");

#print $res->request->as_string;
print $res->as_string;

print "Content saved in $to\n" if $res->is_success;