Hi,
I've written a small file-search program, that reads a directory and uses a
regex in a loop to find matching files.
The problem, is that I can open a file, such as a MS-Works Spreadsheet file
in a text editor, and see the plain-text word that I'm searching for nested
inside the 'gibberish' where the regex can't.
I think it's because the whole file is not getting read into my $searchData
variable.
I think that Perl may be seeing some of that gibberish as a EOF signal, and
quitting the read-in.
In one case, my program thinks a 10,752 byte file should load as a 6
character string!
To load the file as text I use:
######################
...
foreach my $fileName (@list) {
chomp($fileName);
my $duhFileName = $fileName;
#okay, I need help with scope too :-)
if (open SEARCH_FILE, "< $fileName") {
my $searchData = join "", <SEARCH_FILE>;
close SEARCH_FILE;
if ($searchData =~ /(\w*\s*\w*$search\w*\s*\w*)/i) {
push @matchFileList, $duhFileName;
push @matchTextList, $1;
$matches++;
}
} else {
print "Failed to open file '$duhFileName' $!\n<br>";
}
}
#####################
A small note about the '$duhFileName' is for some reason I am yet to deduce
(newbie) Strict gives me an error that $fileName is a global reference, so I
worked around it. My main problem is this trucated file loading problem.
Thanks in advance!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]