use strict; use warnings; use File::Find; my $regexp = shift @ARGV; sub process_file { open FH, $File::Find::name; my $count = 0; while () { if ( print $File::Find::name . " " . $count . "\n" if /$regexp/; $count++; } close; } find(\&process_file, @ARGV);