"Fossies" - the Fresh Open Source Software Archive

Member "libwww-perl-6.43/xt/author/misc/get-file" (26 Nov 2019, 462 Bytes) of package /linux/www/libwww-perl-6.43.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 
    6 use LWP::UserAgent;
    7 
    8 my $file = shift || "";
    9 my $to = $file;
   10 $to =~ s|.*/||;  # only basename
   11 $to = "index.html" unless length $to;
   12 
   13 
   14 my $ua = LWP::UserAgent->new;
   15 #$ua->agent("get-file/0.1");
   16 #$ua->from('aas@sn.no');
   17 
   18 my $res = $ua->request(HTTP::Request->new("GET", "http://localhost:8080/$file"), "$to");
   19 
   20 #print $res->request->as_string;
   21 print $res->as_string;
   22 
   23 print "Content saved in $to\n" if $res->is_success;