in reply to Find, read, write out contents of a certain file type recursively...

This is my way of doing the recursive look for all files in a tree and process those that match a pattern. I'm using DosGlob because I do this on Windows PCs. I'm pretty sure that using regular glob works too but haven't tried it.
use File::DosGlob; $dir= '/home/javascript/*'; # note trailing * !!! my @m = File::DosGlob::doglob(1,$dir); for (@m) { push @m, File::DosGlob::doglob(1,$_.'/*') if -d($_); next unless (/\.js$/); # put your code here to # open file ($_) and search open(JS,"<$_") or die "Can't Open $_: $!"; # etc. }
PS you probably want to open your output file outside the search LOOP!

Dingus


Enter any 47-digit prime number to continue.
  • Comment on Re: Find, read, write out contents of a certain file type recursively...
  • Download Code