Hi,

I am trying to use HTTP::Request::Common;
Its working fine but I want to make the code more generic ... I am POSTing a request with:

my $req = POST $url, Content_Type => 'form-data', Content => [ loaderid => $loaderid, zipped => $zipped, user => $user, filetype => $filetype, file => [ $fname ] ];

What I want to do is have variable number of attributes that I read from a config file such as:

#################### # Load Settings # #################### loaderid = 382 user = Andy zipped = 1 # 0 Not Zipped, 1 Zipped, 2 Gzipped- do not use -1 filetype = 1 # 1 = Measurements, 2 = Outage, 3 = Rotation

Using the following code...

while (<CONFIG>) { chomp; # no newline s/#.*//; # no comments s/^\s+//; # no leading white s/\s+$//; # no trailing white next unless length; # anything left? my ($var, $value) = split(/\s*=\s*/, $_, 2); $preferences{$var} = $value; }

The problem is that I don't know how to allocate variable attibutes in the Content part of the request... really its a formtting/syntax problem more than anything else.

Essentially, I want changes in the config file to be reflected in the POST ... if that makes sense!!!

All assistance would be greatly appreciated.

Andy

In reply to Variable HTTP request. by saab99e

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.