Two changes fixed this:
As ikegami already said, File::Find is your friend.sub search_dir{ my $sub_name = shift; local *SUB; # <---- 1st: In order to have a new *SUB for each recu +rsion... opendir SUB, $sub_name or die "Couldn't open the specified directo +ry: $!"; while(my $file = readdir(SUB)){ next if $file eq "." or $file eq ".."; next if $file eq "output.txt"; $file = "$sub_name/$file"; # <---- 2nd: since you didn't chdir +... print $file, "\n"; if(-d $file){ search_dir($file); }elsif($file =~ /\$\$/){ print OUTPUT "Possible \$\$ file found: $file\n"; } } #close SUB; }
In reply to Re: Subroutine to Search Subdirectories Failing at Filehandle Test
by Perlbotics
in thread SOLVED: Subroutine to Search Subdirectories Failing at Filehandle Test
by BJ_Covert_Action
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |