in reply to searching a text file
Update: Does "***Begin $subject" in the equality test need to be "***Begin $subject\n"?
So much to do here.
Consider reading the file like this:
my $cgi = new CGI; my $subject = $cgi->param('subject'); my @b; { local $/="***Begin Here***\n"; open INF, "< /full/path/to/postall.txt" or die $!; @b = grep { chomp; # remove "***Begin Here***\n", then # remove marker and return true to grep if match s/^\*\*\*Begin \Q$subject\E//; } <INF>; close INF or die $!; } # lines go by for (@b) { s/\n/<br\/>\n/g; } print @b;
Update2: Added chomp, positional ^, and comments to grep code, a litle text cleanup.
After Compline,
Zaxo
|
|---|