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 :-(


In reply to Re: Pattern Search Across Multiple Lines by johngg
in thread Pattern Search Across Multiple Lines by Rajpreet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.