silly mistake...see responses

For some reason I do not understand, in the following piece of code, "$r" is a hash reference. This is an incomplete new function from a .pm file. With the exact same piece of code used outside of a function in a script, "$r" would be a string (the _content from the reply hash), which is what I've expected from LWP::UserAgent up to now, and what the documentation describes.
use LWP::UserAgent; use HTTP::Cookies; sub new { my $self = {}; my $apiphp = "http://localhost/wiki/api.php"; my $header = HTTP::Headers->new(Content_Type => "application/x-www +-form-urlencoded"); my $cjar = HTTP::Cookies->new(file => "/root/perl/mediawiki/cookie +s/mediawiki.cookies", autosave => 1); my $client = LWP::UserAgent->new(default_headers => $header, cooki +e_jar => $cjar) || die "MWUser.pm LWP::UserAgent failed!\n"; my %login = ( 'action' => 'login', 'format' => 'xml', 'lgname' => 'user', 'lgpassword' => 'pass' ); my $r = $client->post($apiphp, Content=>\%login); while (my ($k, $v) = each (%$r)) { print "$k = $v\n"; } }
I've been looking thru the docs for the various HTTP base classes here for a way to set this behaviour but haven't found anything yet.

I'd rather not have to bother with selecting _content from a hashref, I was quite happy with the string. Does anyone know what's up?

In reply to LWP::UserAgent returns hash ref with post [SOLVED] by halfcountplus

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.