the basic plot is, i need to find certain files within a directory tree, and when found, append the contents of all the found files into one giant file... with a couple of exceptions:

root dir: /home/tdawg/workspace/zoo

file(s) to find: list.dat

so i started with find2perl

use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; sub wanted; # Traverse desired filesystems File::Find::find({wanted => \&wanted}, '/home/tdawg/workspace/zoo'); exit; sub wanted {" /^list\.dat\z/s && print("$name\n"); }

now before trying to copy the contents to some giant file (>> giant.file) there are 2 exceptions

1)within the root directory, there is only a subset of those directories i want to traverse. I actually only want to search through /home/tdawg/workspace/zoo/abc1* directories. Of course putting a wildcard in there like that doesn't work. So if zoo contains the dirs:

abc1_dos

beta_dos

prod_tres

abc1

we will only traverse through the abc1_dos and abc1 subtrees.

The next exception is that we don't care about list.dat if its in certain sub-directories. we want to ignore list.dat if its under a dead or baby sub-directory.

/home/tdawg/workspace/zoo/abc1/adult/main/list.dat #yes!

/home/tdawg/workspace/zoo/abc1/dead/list.dat #ignore

/home/tdawg/workspace/zoo/abc1/biped/baby/list.dat #ignore

if someone can help me get to the point where I am working only with the list.dats that i want, it would be much appreciated. Various ways of trying to exclude things like /^baby/s within the wanted sub are not working for me.


In reply to getting picky with File::Find by klink'on

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.