This is an extension of choroba's code here with more tolerance for the blank and comment lines apparently (?) present in the OPed example input file (k.dat below), and reproducing exactly the output format shown here. Add oddball output formats for individual registers as needed.

Script format_multiline_for_output_1.pl:

use 5.010; # needs // operator use warnings; use strict; my $default_format = "%-25s%d %d %d %d %d\n"; my %odd_format = ( 'U_TOP_LOGIC/i_reg_2_/Q' => "%-25s%d %d %d %d %d\n", ); print "Reg pat1 pat2 pat3 pat4 pat5\n\n"; my @values; while (<>) { if (/^\s*$/ or /^\s*#/) { # blank or comment line # do nothing } elsif (my ($size) = /^pat([0-9])/) { $size == 1 + @values or die "Unexpected '$_'"; } else { my ($register, $value) = /(\S+).*\}([0-9])/; my $fmt = $odd_format{$register} // $default_format; printf $fmt, $register, splice @values if 5 == push @values, $value; } } print "########################################################\n";
Output:
c:\@Work\Perl\monks\kshitij>perl format_multiline_for_output_1.pl < k. +dat Reg pat1 pat2 pat3 pat4 pat5 U_TOP_LOGIC/i_reg_2_/Q 1 1 0 1 1 U_TOP_LOGIC/i_reg_3_/Q 1 1 1 1 1 U_TOP_LOGIC/i_reg_4_/Q 1 0 1 0 1 ########################################################
(k.dat taken from the OPed example input file.)


Give a man a fish:  <%-{-{-{-<


In reply to Re^3: Formatted output file with data processing by AnomalousMonk
in thread Formatted output file with data processing by kshitij

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.