in reply to Re^4: File::Find: Return array of "wanted" files
in thread File::Find: Return array of "wanted" files
Yes, in such a case, you want to declare the array before entering the loop. That's what choroba is doing in the suggested code, declaring @found right before entering the loop:
my @found; sub findstuff { my $file = $_; return unless -f $file; my $fullpath = $File::Find::name; if (fgrep(qr/regex/, $file)) { push @found, $fullpath; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: File::Find: Return array of "wanted" files
by alpha-lemming (Novice) on Oct 07, 2013 at 16:21 UTC | |
by Laurent_R (Canon) on Oct 07, 2013 at 17:05 UTC |
In Section
Seekers of Perl Wisdom