http://qs321.pair.com?node_id=244406


in reply to Re: parsing of large files
in thread parsing of large files

Hi arturo,

The solution you presented will overwrite the output-file on each occurance of the section start. Furthermore, writing to closed filehandles isn't a very clean solution, IMHO.

You could try to use the magic '..' operator:

open OUT, '>&STDOUT' or die; while ( <DATA> ) { print OUT if /start-marker/../end-marker/ and !/(start-marker|end-marker)/; } close OUT or die; __DATA__ a b c start-marker d e end-marker f g start-marker h i end-marker j k
This will print the lines within the markers (thus: d,e,h and i in my example) but ignores the markers.

HTH,

(update: fixed some layout issues and used the actual '..' operator instead of the '...' one!).

-- JaWi

"A chicken is an egg's way of producing more eggs."