I have a input file with contents as below:

<mt>llbreserve_Stov1</mt> <mt>llbreserve_Stov2</mt> <mt>preserve_Stov1</mt> <mt>qreserve_Stov1</mt> <mt>qreserve_Stov2</mt> <mt>mnreserve_Stov1</mt> <mt>slmreserve_Stov1</mt> <mt>slmreserve_Stov2</mt> <mt>envreserve_Stov1</mt> <mt>envreserve_Stov2</mt> <mv> <value>MT=DUOSQ2,Eb=43789,Fc=67890</value> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> </mv>

I have written the code(pasting here only the specific code,not all lines)as below:

# Writing output from mt step until mv for reserve meas only $dimens=scalar(keys(%ind)); for ($jj=1; $jj <= $dimens; $jj++) { # Writing output mt reserve meas list print OUTFILE "<mt>$kpi[$jj]<\/mt>\n"; } foreach $value (keys %result) { foreach $ext (keys %{$result{$value}}) { print OUTFILE "<mv>\n"; print OUTFILE "$value".",resv="."$ext<\/va +lue>\n"; for ($jk=1; $jk <= $dimens; $jk++) { # Writing output r meas list result so +rted in the same order than mt list print OUTFILE "$result{$value}{$ext}{$ +kpi[$jk]}\n"; } print OUTFILE "<\/mv>\n"; } } print OUTFILE "$line\n";

The output file which i get after executing the code is

<mt>llbreserve</mt> <mt>preserve</mt> <mt>qreserve</mt> <mt>mnreserve</mt> <mt>slmreserve</mt> <mt>envreserve</mt> <mv> <value>MT=DUOSQ2,Eb=43789,Fc=67890,resv=Stov1</value> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> </mv> <mv> <value>MT=DUOSQ2,Eb=43789,Fc=67890,resv=Stov2</value> <r>0</r> <r>0</r> <r>0</r> <r>0</r>

I can see that there are some blank lines where the combination is not present(Stov1 is present for all meas whereas Stov2 is not present for all.)I am planning to insert a tag like <r></r> in place of blank lines so that further processing of my outputfile is valid. Could you pl. help me to achieve this.TIA


In reply to Perl code to format the text file by inserting tag in blank line by DAN0207

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.