I have just started using LWP and associated stuff, and with it reduced 800 odd lines of inherited roll-your-own socket stuff down to around twenty lines.

It was working, then I put use strict at the top and found a few potential problems. These I fixed, but managed to completely break the program.

Here's my working function:

use LWP::UserAgent; use HTTP::Request::Common; use URI; sub CreatePriorityAccount{ my $query = shift; my $url = new URI(); $url->scheme( 'http' ); $url->host( getLotusServer() ); $url->path_query( LOTUSPRIPATH ); my $res = $ua->request(POST $url, content-type => 'form-data', content => $query, authorization => "Basic " . AUTHORISATION, ); # Get the Notes DocID from the response if ($res->is_success) { my ( $DocID ) = $res->content =~ /The DocID for this event is +([0-9A-F]*)/; LOG "SUCCESS: $name, Doc ID is $DocID"; StoreDocID( $name, $DocID ); } else{ LOG "FAILED: POST $url"; LOG "RESPONSE: ", $res->code, ": ", $res->message; } }
Now if I put  use strict at the top it complains that bareword content is not allowed with strict subs. If I then change the offending line to
'content-type' => 'form-data',
It appears to work, but the content does not get passed to the server!

I know I can put  no strict 'subs' in a block around the call, but I would rather understand what is going on here and do it properly.

Thanks for your wisdom.

2001-03-15 Edit by Corion: Removed CODE tags (or rather, their remnants) from the node title.


In reply to How do I use strict with asub( a = 'b' ) syntax? by Anonymous Monk

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.