Eelco, Since your script reads the whole file into an array, that will certainly cause trouble if the file is big enough. (Because you'll run out of memory.)
The script below should work on any size file -- just tested it on a 500 Mb data file. Maybe it's not elegant, but it seems fast enough. Regards, -Tim Grant $tekst_file = "/www/logs/error_log"; open (IN, "$tekst_file") or die "Can't open input file: $!\n"; my @lines; my $linesWanted = 25; while (<IN>) { $. >= $linesWanted and last; push(@lines,$_); } while (<IN>) { push(@lines,$_); shift(@lines); } close(IN); foreach (@lines) { s/</<\;/g; s/>/>\;/g; } $" = "\n<br>\n"; print "@lines"; exit;