> -----Original Message-----
> From: Matt Herzog [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 23, 2007 15:00
> To: Begin Perl
> Subject: File::Find again
> 
> Hello All.
> 
> I can see why people hate this module but I can't seem to let go.
> I point this script at a deep dir structure that has java .properties 
> files sprinkled throughout it. Right now when I have my regex 
> "hard coded"
> in the file, (.properties$) the search works fine. I need to 
> be able to use
> the variable $searchstring at the command line. Is this even 
> possible? If
> not, is there a way to exclude directories from being returned?
> 
> 
> Thanks.
> 
> use strict;
> use warnings;
> use File::Find;
> use Getopt::Std;
> use vars qw/ %opt /;
> use diagnostics;
> 
> my $args = 't:s:a:';
> getopts( "$args", \%opt );
> my $targetdir = $opt{t};
> my $searchstring = $opt{s};
> my $append = $opt{a};
> 
> find(\&mod, $targetdir);
> 
>         sub mod {
>               return unless ($_ =~ /\.properties$/);
>               print "$_\n"
>               }
> 
        change to  
        return unless ( /\.properties/ );       # don't need the $_
already implied
        return if ( -d $_ );                    # if directory return
        You should have no problem using the searchstring, just make
sure what is being passed is what you expecting.
        
  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449           FAX
http://fedex.com/us 
 

> -- 
> Monkeys are superior to men in this:
> when a monkey looks into a mirror, he sees a monkey.
> 
> -- Malcolm De Chazal
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
> 
> 
> 

**********************************************************************
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**********************************************************************


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to