Eating memory

Jonathan McKeown jonathan at hst.org.za
Tue May 23 13:17:22 BST 2006


On Tuesday 23 May 2006 13:53, Simon Wilcox wrote:
> 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>) {
> }

foreach puts its argument in list context. It would be better to read a line 
at a time in a while loop.

Jonathan


More information about the london.pm mailing list