[Classiccity-pm] Greatest number
Paul Keck
pkeck at uga.edu
Mon Jun 5 11:22:08 PDT 2006
On Mon, Jun 05, 2006 at 02:02:16PM -0400, Linda Dubes Law wrote:
> 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?
tail -1
head -1
will give you the head and tail line. I'd try running it like
system("cat filename | sort -n +3 -4 |tail -1")
and adjust the sort until it sorted on the proper field. See how long that
takes compared to using perl.
If you need to do it in perl alone, then the code you put in looked pretty
good to me. No need to store the lines in an array if that's all you want
out of there. If you're looking at making multiple passes through it, I
suggest sucking it into a hash.
--
Paul Keck pkeck at uga.edu http://www.arches.uga.edu/~pkeck
University of Georgia http://www.uga.edu/ucns/telecom
EITS Network Engineering mailto:pkeck at ediacara.org
--Opinions mine.-- Go fighting anomalocaridids!!!
More information about the Classiccity-pm
mailing list