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:
Output: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";
(k.dat taken from the OPed example input file.)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 ########################################################
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |