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

File::Find was cool ten years ago, but I've gotten older and lazier; instead, I use File::Find::Rule most of the time. This does what you want:
#!/usr/bin/perl -l use strict; use warnings; use File::Find::Rule; my $dir = '/tmp'; my @subdirs = File::Find::Rule->in($dir); my $rule = File::Find::Rule->new; $rule->file; $rule->name('*.txt'); my @files = $rule->in(@subdirs); foreach my $file(@files) { print $file; }
  • Comment on Re: code for serching .txt file through directories and sub directories
  • Download Code

Replies are listed 'Best First'.
Re^2: code for serching .txt file through directories and sub directories
by Anonymous Monk on Jun 12, 2012 at 15:53 UTC

    It really doesn't look like you've used it much

    my @files = File::Find::Rule->file->name('*.txt')->in( $dir );