On Fri, Mar 23, 2007 at 03:09:31PM -0700, Wagner, David --- Senior Programmer
Analyst --- WGO wrote:
> > -----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?
This is all I needed. I swear I had " /($searchstring)/; " in there at
some point before . . . so if I pass it
-s "\.properties$"
at the command line, it works as expetcted. Nice.
################################################################
use strict;
use warnings;
use File::Find;
use Getopt::Std;
use vars qw/ %opt /;
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 /($searchstring)/;
print "$_\n"
}
################################################################
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/