$ua->credentials( 'www.domain.com:80', '', 'user' => 'pass' );

Are you sure that middle parameter should be empty? If it doesn't match the "realm" configured in the server for that location, LWP won't know it is supposed to use these credentials to authorize itself.


In response to your wondering about the => arrow — it does nothing in your example. In fact, it's exactly the same as a comma. The difference is that this so-called "fat comma" lets you leave the left side unquoted, so you could say

$ua->credentials( 'foo:80', 'bar', user => 'pass' ); # needs no quotes

and get exactly the same result. There is no other difference, it's not magical in any way. It's just a bit of syntactic sugar to let you avoid quote noise when you want to. You can even use several of them in a row:

$ua->credentials( 'foo:80', bar => user => 'pass' );

But that quickly gets annoying to look at if you overdo it for no particular reason. It's nice to have when you want to make certain relationships stand out in the code, though. Sometimes, rarely, chaining several of them is actually sensible.

It's just one those little things in Perl.

Makeshifts last the longest.


In reply to Re: LWP Credentials Login Problem to Download Zip Files by Aristotle
in thread LWP Credentials Login Problem to Download Zip Files by noniekimp

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.