wrote in
news:e4bc22af-6e40-4109-a99f-:
> I am new to perl, I have a sample file like this
Sample input snipped here for brevity ... Included with solution below.
> Here is what I have:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> my $fh;
> open($fh, "<test2.rpt") - # test2.rpt is the file containing lines I
> mentioned above.
> or die "Can't open: $!";
Thanks for using warnings and strict as well as checking the return
value of open.
You could write the open call more succinctly as:
my $filename = 'test2.rpt';
open my $fh, '<', $filename
or die "Cannot open '$filename': $!";
> while (my $line = <$fh>) # was $line
> {
> if ($line=~m/Endpoint:/) {
> print "\n";
> #print "$1";
> print "$line";
> }
> }
#!/usr/bin/perl
use strict;
use warnings;
while ( my $line = <DATA> ) {
next unless $line =~ /^Endpoint:/;
print $line;
while ( my $next = <DATA> ) {
last if $next =~ /^Beginpoint:/;
print $next;
}
}
__DATA__
************************************************** **********************
***********
Path 11: VIOLATED Hold Check with Pin core1_2/tx_lr/ifft128/
u7_mem_fft_0/u5_
data_ram_5/\mem_reg[8][13] /CP
Endpoint: core1_2/tx_lr/ifft128/u7_mem_fft_0/u5_data_ram_5/\mem_r
eg[8][13] /D (v) checked with leading edge of 'x_clk'
Beginpoint: core1_2/tx_lr/ifft128/u4_fft_core_top_0/
u0_fft_mux_0/\dout_5_
reg[13] /Q (v) triggered by leading edge of 'x_clk'
Path Groups: {reg2reg}
Other End Arrival Time 0.805
+ Hold -0.017
+ Phase Shift 0.000
- CPPR Adjustment 0.055
+ Uncertainty 0.100
= Required Time 0.834
Arrival Time 0.795
Slack Time -0.039
Clock Rise Edge 0.000
= Beginpoint Arrival Time 0.000
Timing Path:
************************************************** **********************
****************
__END__
C:\Temp> t
Endpoint: core1_2/tx_lr/ifft128/u7_mem_fft_0/u5_data_ram_5/\mem_r
eg[8][13] /D (v) checked with leading edge of 'x_clk'
--
A. Sinan Unur <>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/