use File::Find; my $dir; find( sub { $dir = $File::Find::name if ( /hello\.txt/ ); }, '/tmp/test' );