Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Find maximum number in text file and copying its full statement in new text file?

by jeffa (Bishop)
on May 06, 2015 at 16:22 UTC ( [id://1125859]=note: print w/replies, xml ) Need Help??


in reply to Find maximum number in text file and copying its full statement in new text file?

This "way to do it" uses a hash to find the highest number:

use strict; use warnings; my %candidates; while (<DATA>) { push @{$candidates{$1}}, $_ if /^\s+(\d+)/; } my ($highest) = sort {$b<=>$a} keys %candidates; print for @{ $candidates{$highest} }; __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

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
  • Comment on Re: Find maximum number in text file and copying its full statement in new text file?
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1125859]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found