If all .js files are in a single directory, File::Find isn't the only option.
If you really want to recurse through a directory hierarcy, you can use the code below:opendir(DIR, $jscriptdir) or die("Can't open $jscriptdir"); my @jsFiles = grep(/\.js$/, readdir(DIR)); closedir(DIR); foreach my $jsFile (@jsFiles) { # do whatever }
Hope this helps, -gjb-use File::Find; use IO::File; find(\&wanted, $jscriptdir); sub wanted { if (/\.js$/) { my $fh = new IO::File($_) or die("Can't open $File::Find::dir/ +$_"); while (<$fh>) { # your while here } $fh->close(); } }
In reply to Re: Find, read, write out contents of a certain file type recursively...
by gjb
in thread Find, read, write out contents of a certain file type recursively...
by Ro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |