I have been reading through the File::Find threads trying to find an answer to this question, but wasn't able to quite find it. I want to write the equivalent of this ksh command in perl:
find /h -depth -type f -name *.[!ao] -print
which should find all files, except those of .a or .o I am willing to redirect them to a file, and then read that into a file. (It was difficult for me to follow the redirections for Find::File.)

I was able to get fully qualified pathnames with File::Find, but wasn't able to exclude certain extensions, and I didn't quite follow some of the redirecting of standard output. If I change the default for standard output, does it revert at some point, or do I have to manually reset it?

What just occurred to me now, is the not completely elegant solution of running a ksh script, doing the file find, and then running the perl program, reading the file list from standard input. Maybe that would be easiest....


In reply to Finding files excluding some by david.paige

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.