Instead of changing the code, allow the user to pass some options in. If tachyon would be so kind as to allow me to lift his code:
use strict; use warnings; use File::Find; use Getopt::Long; use vars qw($all @datein @exts @excl $base); GetOptions( 'exts|t=s' => \@exts, 'excl|c=s' => \@excl, 'base|b=s' => \$base, 'all|a' => \$all, ); if (not $all) { @exts = qw( jpg gif tar gz bat txt ) unless @exts; @excl = qw( winnt cygwin ) unless @excl; } $base ||= '/cygwin'; my $exts = join '|', map{quotemeta} @exts; my $excl = join '|', map{quotemeta} @excl; find( sub { push @datein, $File::Find::name if !$exts or m/\.(?:$exts)$/oi and $File::Find::name !~ m!/(?:$excl)!oi ; }, $base, ); print "$_\n" for @datein;
Now you can call the script like so:
./find.pl -exts=txt -exts=gif -excl=nodes -base=.
or this if you want everything:
./find.pl -base=/ -all
If specifying the extensions one at a time becomes too tedious for you, you can rewrite the code to allow the user to pass a delimited string instead. Read up on the Getopt::Long docs for more info. Additionally, check out the Unix command find.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) 3Re: Need help with File::Find by jeffa
in thread Need help with File::Find by ppm

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.