G'day sumathigokul,
Your regex baffles me!
You're trying to match (and capture) one or more digits immediately preceded by and followed with a colon — clearly not what you want.
I'd recommend spending some time with the Perl Regular Expressions Tutorial.
You have no code to output the wanted lines — which is why that part isn't working.
Take a look at open; note how both of the initial examples (for reading and writing) use the 3-argument form and lexical filehandles; start doing this yourself.
This code has the logic you need — you'll need to add the I/O:
#!/usr/bin/env perl
use strict;
use warnings;
my $re = qr{ \A \s+ ( \d+ ) }x;
my $high = 0;
my @lines;
while (<DATA>) {
/$re/ or next;
my $num = $1;
next if $num < $high;
if ($num > $high) {
$high = $num;
@lines = ();
}
push @lines, $_;
}
print "Highest number: $high\n";
print @lines;
__DATA__
High fanout nets in the post compile netlist:
Fanout Type Name
--------------------------
2 INT_NET Net : c_c
Driver: c_pad
2 INT_NET Net : b_c
Driver: b_pad
2 INT_NET Net : a_c
Driver: a_pad
1 INT_NET Net : sum_c
Driver: sum_1_SUM0_0
1 INT_NET Net : N_5
Driver: sum_1_CO0_i
Output:
Highest number: 2
2 INT_NET Net : c_c
2 INT_NET Net : b_c
2 INT_NET Net : a_c
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|