How about something like this?
#!/usr/bin/perl -l use strict; use warnings; $| = 1; require IO::Socket; my $D = shift || ''; if ($D eq 'daemon') { require HTTP::Daemon; my $d = HTTP::Daemon->new(Timeout => 10); print "Pleased to meet you at: <URL:", $d->url, ">\n"; open STDOUT, '>', '/dev/null'; while (my $c = $d->accept) { my $r = $c->get_request; if ($r) { my $p = ($r->uri->path_segments)[1]; my $func = lc("httpd_" . $r->method . "_$p"); if (defined &$func) { &$func($c, $r); } else { $c->send_error(404); } } $c = undef; } print STDERR "HTTP Server terminated\n"; exit; } require URI; my $base = URI->new('http://192.168.1.1'); sub url { my $u = URI->new(@_); $u = $u->abs($_[1]) if @_ > 1; $u->as_string; } print "\tWill access HTTP server at $base"; require LWP::UserAgent; require HTTP::Request; require HTTP::Cookies; my $ua = new LWP::UserAgent; $ua->agent("Mozilla/0.01 " . $ua->agent); my $cookies = new HTTP::Cookies( file => '/tmp/cookies.txt', autosave => 1, ignore_discard => 1, ); $ua->cookie_jar($cookies); my $req = new HTTP::Request POST => url( 'http://192.168.1.1/wiki/index.php?title= Special:Userlogin&action=submitlogin&wpName= readuser&wpPassword=letmein', $base); my $res = $ua->request($req); print $res->as_string;

In reply to Re: LWP UserAgent to script Mediawiki reads by Khen1950fx
in thread LWP UserAgent to script Mediawiki reads by Sabalon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.