As I can see it you have 2 problems:

I will try to address then in that order (tho mabey not very well).

1. Parsing a text file.
To start with, is there any need to do a multiline regex? Unless you've formatted the datafile for our sake, one line at a time ough to work just fine.

foreach $line (@file) { chop $line; if ($line =~ /^get (.+)$/) { push (@getrequest, $1); } if ($line =~ /^post (.+)$/) { $postrequest = $1; $dataread = "true +"; } if ($dataread eq "true") { if ($line =~ /content-type: (.+)/) { $post{$postrequest}{content-type} = $1; if ($post{$postrequest}{content-type} =~ /; boundary=(.+)/ +) { $boundary = $1; } else { $boundary = ""; } } if ($line =~ /content-length: (.+)/) { $post{$postrequest}{con +tent-length} = $1; } if ($line eq "" && $boundary = "") { $contentnextline = "true" +; } if ($contentnextline eq "true") { $post{$postrequest}{content} + = $line; $contentnextline = "false"; $dataread = "false"; } if ($line eq $boundary && $boundary ne "") { $content_flag = " +true"; } if ($line eq $boundary && $content_flag eq "true") { $content_ +flag = "false"; $dataread = "false"; $post{$postrequest}{content} = \ +@content; } if ($content_flag eq "true") { push (@content, "$line\n"); } + }
Now this should (i haven't tested it) create an array and a hash of hashes with all the data you need for part 2.

Update: Ack! this post made it through. My browser hung on the submit. I didn't think it made it, and i had to run out before finishing....

Now for part 2.
You may not want to do it this way, but use the "LWP" module. It is going to give you the best, cleanest, and simplest way for the http submits.
The link above should contain all the docs you need to create the http requests.

Just loop through the elements in the get array, and the hash, and use the data to formulate the requests.

BTW- I have not tested any of the code. It would probably have to be debugged and tweaked to fit your needs.


In reply to RE: multiline regex by bastard
in thread multiline regex by jcr

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.