in reply to 'Permission Denied' error from File::Find
Hope this helps!#!c:\perl\bin\perl.exe -w use strict; use File::Find; use Carp; #variables my ($directory,$file,$text); print "Enter search text: "; $text = <STDIN>; chomp $text; $directory = 'c:\my_directory'; find (\&search,$directory); sub search { my $file = $File::Find::name; if (-r $file && -f $file) { open (FILE, "$file") or carp "Guess what, it didn't work!\n$!"; my $line = <FILE>; close FILE; print "$text - $file" if $line =~ /$text/; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: 'Permission Denied' error from File::Find
by witandhumor (Pilgrim) on Feb 12, 2004 at 03:18 UTC |