CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: endless loop : Edit Log



esolve
New User

Oct 24, 2012, 10:37 AM


Views: 863
endless loop

I want to extract the content except http header from tcp flow files
the content is like the following
the http header ends when two ^M are met

Code
HTTP/1.1 200 OK^M 
Last-Modified: Sat, 20 Mar 2010 09:43:12 GMT^M
Content-Type: video/x-flv^M
Date: Wed, 24 Oct 2012 14:34:13 GMT^M
Expires: Wed, 24 Oct 2012 14:34:13 GMT^M
Cache-Control: private, max-age=22124^M
Accept-Ranges: bytes^M
Content-Length: 29833281^M
Connection: close^M
X-Content-Type-Options: nosniff^M
Server: gvs 1.0^M
^M
FLV^A^E^@^@^@ ^@^@^@^@^R^@^CK^@^@^@^@^@^@^@^B^@
onMetaData^H^@^@^@^O^@^Hduration^@@i<97>
=p£×^@ starttime^@^@^@^@^@^@^@^@^@^@^Mtotalduration^@@i<97>


my code for extraction is as follows,
and I run : extract.pl < tcp.flow
but it seems the loop is endless,
what is wrong with the codes? thanks!

Code
#!/usr/bin/perl 
$start=0;
$data="";
while(<STDIN>)
{
if ( $start eq 0 && $_ =~ /^\r\n/) { $start = 1; }
elsif ( $start eq 1 ) { $data = $data . $_; }
}
open(FH, ">sample.flv");
print FH $data;
close(FH);



(This post was edited by esolve on Oct 24, 2012, 10:38 AM)


Edit Log:
Post edited by esolve (New User) on Oct 24, 2012, 10:38 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives