Hi,
I am unable to use this script. It gives the output file with
the lines until the keyword is found. after the first occurance of the
keyword, starting from there all lines are getting deleted.
I am adding code for your reference. I want to find out ENUMERR which
is there in the line no.11. my resultant output file should not have
line no: 9,10,11. Remaining all should be intact.
Thanks in Advance
rajesh
endtask : collect_e_daita
3 |
4 ncvlog: *W,LBLMAT (../_src/_hard/_vc/lcdport_vc/sv/
nec_lcdport_vc_etype_monitor.sv,1 68|24): Label/name mismatch:
collect_e_data - collect_e_daita.
5 (`include file: ../_src/_hard/_vc/lcdport_vc/sv/
nec_lcdport_vc_etype_monitor.sv line 168, `include file: ../_src/
_hard/_vc/lcdport_vc/sv/nec_lcdport_vc_top.sv line 47, `include
file: ../_src/_hard/_tb/_lcdbif_top.sv line 26, file: ../_src/_hard/
_tb/nec _lcdbif_tb_top.sv line 39)
6 apb_trans_cov.sample();
7 |
8 ncvlog: *W,ECSSDM (./INCA_libs/irun.lnx86.06.20.nc/svpplib/h/
sivajar/lcdbif/_veri/_rando m/_src/_hard/_uvc/apb_uvc/sv/
apb_uvc_master_monitor.sv,149|24): The 'sample' met hod is called
upon a covergroup instance whose declaration has a default sampling
condit ion associated with it.
9 `ovm_field_int (rd_wr, OVM_ALL_ON)
10 |
11 ncvlog: *W,ENUMERR (../_src/_hard/_uvc/apb_uvc/examples/../
examples/dummy_memconfig_ types.sv,8|46): This assignment is a
violation of SystemVerilog strong typing rules for enumeration
datatypes.
12 `ovm_field_int (rdy_int, OVM_ALL_ON)
rajesh said:
I need a parser logic in perl. I need to read a log file line by
line and search for a keyword. Once the keyword is found in any line,
I need to remove the previous two lines and current line. My new log
file, should not have these three lines.
On most systems files are simply a sequence of bytes and you
can't cut out something from the middle. It's not like a deck
of cards, where each card is a line in the file, and where
you can pull out a few cards from the middle. You have to
copy everything from the old file to a new one (of course ex-
cept the bits you want to remove) and then replace the old
file by the new one. So in your case you have to keep three
lines in memory, writing the oldest one out if the newest
one does not contain the keyword you were looking for. Only
if it's in the newest line forget about the three lines and
copy all the rest of the contents of the old file to the new
one. Something like this should do:
#!/usr/bin/perl
use strict;
use warnings;
open my $in, '<', 'log' or die "Can't open log file.\n";
open my $out, '>', 'log.new' or die "Can't open replacement file.\n";
my @lines;
$lines[ 0 ] = <$in>;
$lines[ 1 ] = <$in>;
while ( <$in> ) {
if ( /KEYWORD/ ) {
while ( <$in> ) {
print $out $_;
}
last;
}
print $out shift @lines;
push @lines, $_;
}
close $out;
close $in;
rename 'log.new', 'log';
Regards, Jens