in reply to Pattern Search Across Multiple Lines
If I have understood correctly, you could localise the input record separator (see $/ or $INPUT_RECORD_SEPARATOR in perlvar) to your closing tag then use tr to remove embedded newlines.
With this input data
$ cat spw822595.inp <MyId><data>1332</data><blarg>burfle bof bip blech</blarg></MyId><MyId><data>1332</data><spu>hsh wugw </spu> <spog>uh wef wegf</spog></MyId> <MyId><data>1332</data><grop>hd wg fw we we we we eryer efy we dad</grop></MyId> $
This code
use strict; use warnings; my $inFile = q{spw822595.inp}; open my $inFH, q{<}, $inFile or die qq{open: < $inFile: $!\n}; my $outFile = q{spw822595.out}; open my $outFH, q{>}, $outFile or die qq{open: > $outFile: $!\n}; { local $/ = q{</MyId>}; while ( <$inFH> ) { tr{\n}{}d; print $outFH qq{$_\n} if $_; } } close $inFH or die qq{close: $inFile: $!\n}; close $outFH or die qq{close: $outFile: $!\n};
Produces this output
$ cat spw822595.out <MyId><data>1332</data><blarg>burfle bofbip blech</blarg></MyId> <MyId><data>1332</data><spu>hsh wugw </spu><spog>uh wef wegf</spog></M +yId> <MyId><data>1332</data><grop>hd wg fw we we we weeryer efy we dad</gro +p></MyId> $
I hope I have understood correctly and this is of use.
Cheers,
JohnGG
Update: Just spotted a horrible typo in first paragraph, s{\$\.}{$/} has put things right :-(
|
|---|