in reply to file wildcards in Win32
will then look through all Source code on C for the beginnings of comments.usage: greplike.pl C:\ .c /*
use File::Find; use strict; use integer; my $filecounter = 0; my $dir = @ARGV[0]; @ARGV[1] =~ m/(.*)(\.){1}(\w+)$/g; my $filename = $1; my $filesoftype = $3; my $stringtosearchfor = @ARGV[2]; print "Looking for files of type $filesoftype in $dir containing $stri +ngtosearchfor\n"; sleep 10; find(\&lookingfor, $dir); print "Found $filecounter files of type $filesoftype!\n"; sub lookingfor() { if (($_ =~ m/\.+($filesoftype)+$/io) && (-f $_)) { $filecounter++; open INPUT, "<$_" || die "Unable to open $_ for examination: $ +!\n"; while(my $line = <INPUT>) { chomp $line; if ($line =~ m/$stringtosearchfor/gio) { print "Found match in $File::Find::name at line $.\.\n +"; } } close INPUT; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: file wildcards in Win32
by Ovid (Cardinal) on Jun 16, 2000 at 23:32 UTC | |
by buzzcutbuddha (Chaplain) on Jun 17, 2000 at 01:21 UTC |