Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Reading chunks of data and then working on it

by Roy Johnson (Monsignor)
on Feb 26, 2008 at 19:45 UTC ( [id://670372]=note: print w/replies, xml ) Need Help??


in reply to Reading chunks of data and then working on it

One way:
#!perl use strict; use warnings; while (<DATA>) { if (my ($bbegin) = /^(=+KEYWORD \d+)/) { my $block_o_text; while (1) { $_ = <DATA>; /^${bbegin}_END/ ? last : ($block_o_text .= $_); } print "Do something with $block_o_text\n"; } } __DATA__ ========KEYWORD 1=========== Text text text ========KEYWORD 1_END======= ========KEYWORD 2=========== Text text text ========KEYWORD 2_END======= ========KEYWORD 3=========== Text text text ========KEYWORD 3_END=======

Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://670372]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found