in reply to code for serching .txt file through directories and sub directories

Look at this code and check for differences. Your -f test was being regexed, not the filename. Also you filled your array improperly.
#!/usr/bin/perl use warnings; use strict; use File::Find; find(\&file_names, '.'); my @files; print "@files\n"; sub file_names { # if( -f && $File::Find::name=~/(.*).txt$/) #bad usage of .* if( -f && $File::Find::name=~/\.txt$/) # thanks davido :-) { print "$File::Find::name\n"; push @files, $File::Find::name; } }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh
  • Comment on Re: code for serching .txt file through directories and sub directories
  • Download Code