jcr has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: multiline regex
by bastard (Hermit) on Oct 17, 2000 at 04:44 UTC | |
|
Re: multiline regex
by chromatic (Archbishop) on Oct 17, 2000 at 04:26 UTC | |
|
Re: multiline regex
by AgentM (Curate) on Oct 17, 2000 at 01:51 UTC | |
|
Re: multiline regex
by jcr (Initiate) on Oct 17, 2000 at 03:45 UTC |