Eating memory
Robin Barker
Robin.Barker at npl.co.uk
Tue May 23 13:11:28 BST 2006
-----Original Message-----
From: Simon Wilcox [mailto:essuu at ourshack.com]
Sent: 23 May 2006 12:53
To: London PM
Subject: Eating memory
Sorry, I have a perl question :-)
I've been working on a simple script to munge some logs and produce some
stats but top suggests that it's loading the whole file into memory when I
think it should be working line by line. This is obviously not good when
there are gigs of logs to look through.
I've reduced the script to the simplest case but it is still not reading
the file line by line. I must be doing something stupid - can anyone see
what it is ?
#! /usr/bin/perl
use warnings;
use strict;
my $filename = $ARGV[0];
open INFILE, "$filename" or die "Can't open file : $!\n";
foreach (<INFILE>) {
}
-----
Try
while(<INFILE>) {
?
Robin
-------------------------------------------------------------------
This e-mail and any attachments may contain confidential and/or
privileged material; it is for the intended addressee(s) only.
If you are not a named addressee, you must not use, retain or
disclose such information.
NPL Management Ltd cannot guarantee that the e-mail or any
attachments are free from viruses.
NPL Management Ltd. Registered in England and Wales. No: 2937881
Registered Office: Serco House, 16 Bartley Wood Business Park,
Hook, Hampshire, United Kingdom RG27 9UY
-------------------------------------------------------------------
More information about the london.pm
mailing list