Code:
$ cat infile
5'h1f, 16'h8210
write, 5'h10, 16'h0000
write, 5'h11, 16'h0000
5'h1f, 16'hffd0
write, 5'h1e, 16'h0000
5'h1f, 16'h8310
read, 5'h10, rd_data
5'h1f, 16'hffd0
read, 5'h1e, rd_data
write, 5'h1e, aerstrap
$ cat script.pl
use warnings;
use strict;
die qq[Usage: perl $0 input-file\n] unless @ARGV == 1;
my ($begin_line);
while ( <> ) {
next if m/\A\s*\z/;
chomp;
if ( m/\A5'h1f/ ) {
$begin_line = $_;
next;
}
printf qq[%s\n], join qq[, ], $begin_line, $_;
}
$ perl script.pl infile
5'h1f, 16'h8210, write, 5'h10, 16'h0000
5'h1f, 16'h8210, write, 5'h11, 16'h0000
5'h1f, 16'hffd0, write, 5'h1e, 16'h0000
5'h1f, 16'h8310, read, 5'h10, rd_data
5'h1f, 16'hffd0, read, 5'h1e, rd_data
5'h1f, 16'hffd0, write, 5'h1e, aerstrap