use File::Find; find(\&wanted, @files); sub wanted { $found ||= $File::Find::name if $_ eq "$item.dat"; }