perl -e 'open my $outfh, ">", "sample.txt"; while ($i++ < 50_000_000) {print $outfh "abcdefghijklmnopqrstuvwxyz0123456789\n";}' #### perl -E 'open my $infh, "<", "sample.txt"; while(<$infh>) {$i++} say $i;' #### my %dispatch = ( sample => sub {my $capture = shift; # do something with $capture}, good => sub {my $capture = shift; # do something with $capture}, ); while() { if (/^(sample|good)\s+(\S+)/) { $dispatch{$1}->($2); } }