illitrit has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use File::Find; my($find, @directories) = (@ARGV); unless (scalar @directories) { print "Usage: find.pl FINDSTRING DIR1...\n"; exit; } find(\&do_this, @directories); exit; sub do_this { if(! -f $_) { # if it's not a regular file skip it return; } if(open(F, $_)) { undef $/; my $file = <F>; if((defined $file) && ($file ne '') && ($file =~ /\Q$find\E/giso)) { # the if defined was added # later after I realized that an # empty file would leave $file undef! print "$File::Find::name\n"; } close(F); } else { warn "Unable to open '$_': $!"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is this normal for File::Find or where did I go wrong.
by mr.nick (Chaplain) on May 03, 2001 at 06:40 UTC | |
|
Re: Is this normal for File::Find or where did I go wrong.
by converter (Priest) on May 03, 2001 at 06:09 UTC | |
by illitrit (Friar) on May 03, 2001 at 06:17 UTC | |
|
Re: Is this normal for File::Find or where did I go wrong.
by Sinister (Friar) on May 03, 2001 at 16:44 UTC |