[thelist] pattern matching mail in perl

Adrian Fischer adrian at logo-logic.com
Fri Nov 10 06:50:10 CST 2000


Well I guess you ve caught on by now....I haven't a clue what I'm doing
here!

At last I can get access to the .mail file on the linux server that hosts
me.  If its sin a useable format is yet to be seen.  At present I can dump
the whole thing to screen, but that's not what I want, it just proves to me
that I've accessed it.
This is how I'm doing it:
<snip>
death('didn't work') unless (open(MAILFILE, "$config{'pathtomail'}.mail"));
 (@junk) = <MAILFILE>;
close MAILFILE;
  print "@junk
</snip>

the print just dumps the whole file (possibly many emails) to the screen, no
formatting.  It doesn't need to be formatted.  I don't want it displayed on
the screen.  I want to be able to search the file and find occurrences of
certain key words and then see whets on the right of them.  For instance.
Find occurrences of the word "Invoice Number:" and return the number to the
right of it. There may be many instances of the word "Invoice Number:" and I
need to have them all returned.

I think part of my problem is that the file is not delimited by anything.  I
know if I do this:
<snip>
death('it don't work') unless (open(MAILFILE,
"$config{'pathtomail'}.mail"));
 ($crap,$snap,$pop,$q1,$q2,$q3,$q4......etc) = <MAILFILE>;
close MAILFILE;
  foreach ($crap)
 {
print "$crap...$snap...$pop...$q1...$q2...$q3...$q4....................etc";
 }
</snip>
it seems to print a line at a time so perhaps there is a line feed at the
end of each row (obviously) and each variable is grabbing a line.  That's a
step in the right direction.  But I don't know how many emails may be in the
file at a given time so that doesn't really help.

Even a line at a time ( If I could somehow do a while loop and grab and test
each line as it reads the file might work) might be to much.  Perhaps if I
could grab each individual word and test it against my search word.

And there in lays the problem.  I know what I need to be doing but don't
know how to do it.  My reference talks about pattern matching but does not
give an example that I can play with.  I've searched online resources for
examples but found nothing.

Once I've grabbed the variables I need from the mail the rest is
easy...update my db and away we go.  But it could all be for naught if I
cant get this sucker to work.

Any online resources you know of that are in big black bold print (with
pictures would help).  Examples are what I really need.  I've managed to get
this far by playing with examples and chopping and changing them.

Could be a big ask on a Friday (its actually 1045 pm Friday night as I write
this but I'm hoping someone on the other side of the world has nothing
better to do on their Friday.;-))

Sorry to hassle you all so many times in one day...


Regards

(a very battle weary)
Adrian Fischer
Brisbane
Australia





More information about the thelist mailing list