[Classiccity-pm] Greatest number

Linda Dubes Law lindadl at uga.edu
Mon Jun 5 11:02:16 PDT 2006


I am trying to figure out an efficient way to get the greatest number in a file.  The file is rather large.  Should I do something like:
*********************
while (<DPCARDS>) {
	chomp;
	($cardnumber) = (split / /) [1];
	if ($cardnumber gt $largest) {
		$largest = $cardnumber
*********************

Or should I read everything in an array and then sort the array 

Or should I go to the system, sort the file and then is there some way to read in only the last record of a file?  Or perhaps sort descending and then read in only the first record?

As always, your input is appreciated!

Thanks, 

Linda Law



More information about the Classiccity-pm mailing list