If I was faced with trying to do something like this, I would probably modify the input record separator to automatically break the text into chuncks and then parse it from there.
{ local $/ = '~~'; while (my $record = <DATA>){ chomp $record; $record =~ s/\n//g; # then do what you want with the records print +($record =~ /^T/) ? ' ' : '', "$record\n"; } } __DATA__ He0Hello~~He2W~orld~~He0Hello~~He2W~orld~~He0Hello~~He2W~orld~~He0Hell +o~~He2W~orld~~ He0Title1~~Te1~~Te2~~Te3~~Te4~~He1Title1~~Te5~~Te6~~Te7~~Te8He1Title2~ +~Te9~~Te10~~Te11~~Te12~~ He0Hello~~He2W~orld~~He0Hello~~He2W~orld~~He0Hello~~He2W~orld~~He0Hell +o~~He2W~orld~~ He0Title1~~Te1~~Te2~~Te3~~Te4~~He1Title1~~Te5~~Te6~~Te7~~Te8He1Title2~ +~Te9~~Te10~~Te11~~Te12~~ He0Hello~~He2W~orld~~He0Hello~~He2W~orld~~He0Hello~~He2W~orld~~He0Hell +o~~He2W~orld~~
In reply to Re: Get chars between 2 markers using regular expressions
by thundergnat
in thread Get chars between 2 markers using regular expressions
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |