There's a few bits of your sample code that don't seem right:
- There's no need to chomp the filename. (harmless though)
- It's odd that you should specify $_ in the pattern match, since
you appear to understand how to use it as the default for the split
command later. (also harmless)
- Why are you splitting the filename on whitespace? The variable $_
contains only one filename, because the subroutine is being called once
for each file. It looks like you think that $_ contains a list of filenames...
- Even so, I don't see why your code wouldn't recurse.
It just doesn't do what you want.
Your test sub could be written more simply:
sub get_good_int {
next if /^unknown/;
print "My filename is: $_\n";
}
Something closer to being useful might be this:
use File::Find;
use File::Basename;
find (\get_good_int, '/nfs/export/netflow/intermediate');
sub get_good_int {
next if /^unknown/;
# If the directory path includes this type of dir
if ($File::Find::dir =~ m#/questionable-\d{6}-\d{6}#) {
myfunc1($_);
}
# If it contains this other type of dir
elsif ($File::Find::dir =~ m#/\d{6}-\d{6}#) {
myfunc2($_);
}
}
buckaduck
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.