use strict; use warnings; use File::Find; find( sub { my $f = $File::Find::name; return unless $f =~ /\.p(l|m)$/; return unless open my $fh, "<", $f; while(<$fh>){ print "$f: $_" if /^\s*use if/; } close $fh; }, @INC );