Hello,

I am trying to read a file consisting of HTTP GETs and POSTs. I've got the GETs working, but I am having problems getting the POSTs working. I want to construct a complete HTTP POST request from the info in the file (plus some other stuff)

Here is what the file i'm reading looks like:

get /servlet/folder/Create post /servlet/folder/CreateAction content-type: application/x-www-form-urlencoded content-length: 38 FolderName=Data+Source+Tests&B1=Create get /servlet/folder/List get /pix/jsmenu.js post /servlet/datacab/FileNewUploadAction content-type: multipart/form-data; boundary=-------------------------- +-7cf29e18894 content-length: 1632 -----------------------------7cf29e18894 content-disposition: form-data; name="UploadedFile"; filename="mylarge +file" content-type: text/plain Index Date Created CCK Std suite city state ZIP/P +ostal Country first title type of biz distribution +bundle? 6 mo forecast next 6 month

I want to isolate (1)the relative URLs as well as the (2) content length and (3) the entire post body.

How can I do this with a simple regex?

This is what I have so far, but it does not work!

open(FILE, $scriptfile) || die "Cannot Open $scriptfile\n$!\n"; undef $/; $_ = <FILE>; if ($_ =~ /post\s(.+\n)(.+\n)content-length:\s(\d+\n\n)(.+\n)/s) { +print "relURL: $1\nContent length: $3\npost_body: $4\n\n"} close(SCRIPT);

thanx,

jcr


In reply to 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.