I have a directory structure, for example:
/nfs/export/netflow/intermediate/ /nfs/export/netflow/intermediate/200101-200102 /nfs/export/netflow/intermediate/200103-200104 /nfs/export/netflow/intermediate/questionable-200101-200102 /nfs/export/netflow/intermediate/questionable-200103-200104 /nfs/export/netflow/intermediate/current@ /nfs/export/netflow/intermediate/previous@
I want the code to look for any directory(s) beginning with "questionable", and any directory(s) matching the date-range convention of yyyymm-yyyymm. I am using File::Find to recurse through the top-level directory. Here's my problem: I need to process files contained the directories
/nfs/export/netflow/intermediate/200101-200102 /nfs/export/netflow/intermediate/200103-200104
differently than the files contained in:
/nfs/export/netflow/intermediate/questionable-200101-200102 /nfs/export/netflow/intermediate/questionable-200103-200104
HOWEVER, the files contained in both the "questionable" directories and the "yyyymm-yyyymm" directories are named using the same convention.

File names in either directory will be, for example:
bgp-nexthop.chicago4-cr8.20010307.gz or unknown-prefix.chicago4-cr8.20010307.gz

I know that File::Find will ignore any symlinks by default, which is what I want. But, I'm not sure how to pass separate functions to files, based upon what directory they reside in.
Here's some code:
#!/usr/local/bin/perl -w use strict; use File::Find; my $intdir = "/nfs/export/netflow/intermediate"; find(\&get_good_int, $intdir); sub get_good_int { chomp; next if ( $_ =~ /^unknown/); my @list = split; foreach my $file (@list) { print "My filename is: $file\n"; } }
This prints the contents of "intermediate", without recursion. Obviously, the subroutine, &get_good_int doesn't do any thing useful yet, but I want to make sure that I'm grabbing the correct files, first. From reading other posts re: File::Find, I think that it is wise to mention that I am on a machine running 5.003_26.

In reply to File::Find Question by Tuna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.