Hi, please post an SSCCE. The code you have shown does not compile. It certainly looks as if your solution does not need to be this complicated, but it's hard to know since the code is incomplete.
Your problem description is also unclear. "I want to go into first directory/i/j/*" -- this path does not look like a directory.
If you haven't yet done so, take a look at the module I recommended in your previous thread, Path::Iterator::Rule. Or another module by the same author, Path::Tiny, which provides the handy visit() method. The following should do what you want:
use strict; use warnings; use feature 'say'; use Path::Tiny; use List::Util 'any'; my $regexp = qr/(?:TbhODK|octuov|qas_uop)/; my $found = path('/some/path')->visit( sub { my ($path, $results) = @_; return if $path->is_dir; $results->{$path}++ if any { /$regexp/ } $path->lines; }, { recurse => 1 }, ); say for keys %{ $found }; __END__
Hope this helps!
In reply to Re: Loop through all directory and files and lines
by 1nickt
in thread Loop through all directory and files and lines
by MissPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |