use strict; use File::Find; find( sub { return 1 if -d; my @chunks = read_file() =~ /^[^\n]*\border\b.{1,30}\bof\b[^\n]*/gims; return unless @chunks; print "$File::Find::name: @chunks\n\n" }, "." ); sub read_file { local $/; local @ARGV; push @ARGV, (@_ ? @_ : $_); <> }