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


in reply to Extract individual lines and block of text from large files

You could add an inner loop:
{ $htm = join('',$1,$2,$3,$4); while ( my $htm_line = <$FH_IN> ) { last if $htm_line =~ m/^\s*<\/DOCUMENT>/i; $htm .= $htm_line; } }
Note that you need to escape the '/' in the DOCUMENT tag.