#!/usr/bin/env perl use warnings; use strict; use Time::HiRes qw( time ); my $file = shift @ARGV; my ($fh, $time); open $fh, "<", $file; $time = time; while(<$fh>) { /^ ?Query/; } printf "%f read lines from disk and do RE.\n", time - $time; seek $fh, 0, 0; my $s = ""; while(<$fh>) { $s .= $_; } open $fh, "<", \$s; $time = time; while(<$fh>) { /^ ?Query/; } printf "%f read lines from in-memory file and do RE.\n", time - $time;