#!/usr/bin/perl
# by Philip Shuman  -- philip at shuman dot org
# v0.0.1

require LWP::UserAgent;
use CGI qw(:standard);
if (!param()) {
    print header;
    print start_html('url2uue'),
    p,
    h1('url2uue'), "\n",
    start_form,
    #"Enter your url ",textfield('url'),
    "Enter your url ",
    textfield(-name=>'url', -default=>'', -size=>50, -maxlength=>200),
    submit,
    end_form, "\n",
    p;
    print end_html;
}
else {
    print "Content-type: text/plain\n\n";

    print "URL requested: ",(param('url')), "\n";
    my $ua = LWP::UserAgent->new(env_proxy => 1,
                                 keep_alive => 1,
                                 timeout => 30, );

    $request = HTTP::Request->new('GET', param('url'));
    $response = $ua->request($request, '/tmp/sss');
    `uuencode /tmp/sss sss.uue > /tmp/sss.uue`;

    open (FILE,"/tmp/sss.uue") || die "Can't Open file: $!\n";
    @LINES=<FILE>;
    close(FILE);
    foreach $line (@LINES) {
        print "$line";
    }
    `rm /tmp/sss /tmp/sss.uue`;
}


