test_pre.pl: use strict; open(DATA, ">", "test.dat"); foreach (1..$ARGV[0]) { print DATA "$_\n"; } close(DATA); #### test_slurp.pl: use strict; use constant SIZE => 10000; my $t0 = time(); my $lines = read_log_s(); my @data = (0..SIZE - 1); foreach my $line (@{$lines}) { $line += ($data[$line % SIZE] - $data[($line + 1) % SIZE]); } print "Used ", time() - $t0, "\n"; sub read_log_s { local $/; open(FILE, "<", "test.dat"); my @lines = split /\n/, ; close(FILE); return \@lines; } test.pl: use strict; use constant SIZE => 10000; my $t0 = time(); my @data = (0..SIZE - 1); open(FILE, "<", "test.dat"); my $line; while ($line = ) { $line += ($data[$line % SIZE] - $data[($line + 1) % SIZE]); } close(FILE); print "Used ", time() - $t0, "\n";