use strict; use warnings; use XML::Twig; use File::Find; my $file ='\Users\ADMIN\Documents\probe'; my $FileResult = 'result.txt'; open( my $FhResult, '>', $FileResult )or die ("Unable to open file $FileResult\n$!"); find(\&wanted, $file); sub wanted { print $FhResult "Found it $File::Find::dir/$_\n" if /^[d or t]/i; }