I'm writing a home boy mail/news search tool and wondered if there is
a cononical way to handle folded or indented header lines.

An example would be that I wanted to run a series of regex against each
line of input (While in headers) grabing the matches into an array
for printing.

Something like:
[...] snipped getopts and other unrelated stuff
      while(<FILE>){
          chomp;
          my $line = $_;
          ## @hdregs is an array of several regex for the headers
          for($ii=0;$ii<=$#hdregs;$ii++){
             if($line =~ /$hdregs[$ii]/){
                ## Capture the line
                push @hits,$line;
             }
          } 
    }
          (somewhere later... if some body regex also match....
            print the hits.)

I used a for loop so as to stop at each incoming line and compare it
to a number of regex in rotation, instead of using a possibly long
string of alternation operators (if ($_ =~ /regex|regex2|regex3/)  etc

But going this route means lines like `Received: ' lines that might
have folded (indented) lines containing newlines after them will get
missed.

It seems like it might take some fairly complex code to do something
like above but include slurping the indented lines on hits that have
them.   I wondered if there is some well worn way to do this?

Or is it necessary to process the entire header... making single
lines out of the indents before doing the matching?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to