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.

  1. #!/usr/bin/perl -w Warnings on.
  2. use strict; aid in debugging.
  3. use CGI; You'll get toasted for parsing $QUERY_STRING
  4. $| = 1; Let through whatever gets printed right away.
&dienice does nothing that use CGI::Carp qw(fatalsToBrowser); can't do better.

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