If each record has a consistent separator you can set $/ equal to it,
which changes the default value of $_ (normally a newline).  I think
the value of $/ is normally thrown out in these cases so setting it
to the email might not work.

#!/bin/perl

$recordseparator = "########";      # or whatever your separator is
$/ = $recordseparator;

while (<STDIN>)
{
    my @array = $_;     # this includes entire record now, not just a line
    foreach my $line (@array)
    {
        # process lines of record, match regexs, store variables, etc
    }
    # construct your mail message, send it off
}   # on to the next loop iteration (next email)

Or you could make it two tasks - if they are fixed length you could
use unix "split" to splinter them into separate records, or you could
use a really simple perl command to just open a new file (and close the
previous one) whenever it reaches the new email address.  Then write
a perl script to process one record and call it on every file.

lots of ways.  Some perl guru out there could probably give you a 
one-liner.

Curt

On Mon, Apr 03, 2000 at 03:42:12PM -0700, Bob Thompson wrote:
> umm, here's my problem..  I think I have a resonable facsimile of a
> script, but still have some questions..  I could send it along.. having
> only about 20 lines.
> 
> thanks much for any replies
> 
> bob
> 
> ---------- Forwarded message ----------
> Date: Mon, 3 Apr 2000 14:55:23 -0700
> From: EFN Member Service <[EMAIL PROTECTED]>
> To: Bob Thompson <[EMAIL PROTECTED]>
> Subject: Re: Bash
> 
> On Mon, Apr 03, 2000 at 02:39:56PM -0700, Bob Thompson wrote:
> 
> >Patrick..
> >     Having nothing at all, to do with 'bash'..  but your message
> >arrived at the right time.  Do you do Perl?  Can I ask you a few
> >questions about it, if so?   I'm trying to write a little script to parse
> >a file into a bunch of mail-messages..  this file has 100+ reports, done
> >on data submitted by individuals to a survey, each preceeded by the e-mail
> >address of the person.  The reports are a fixed length.  I figured it was
> >a natural for Perl, but don't know that much about it.   ..in particular
> >how can one read  the file, line by line, extract the address and put it
> >into a To: line, provide the remainder of information, and have it loop
> >through the rest of the report, dumping into a new message as it goes,
> >finally sending it off..!
> >
> >bob
> >
> 
> My knowledge of Perl is very limited (sorry :-( ), but what you describe
> sounds like what i've heard Perl being designed for.  Perhaps if you were 
> to ask on the Eugene Linux User's Group list, [EMAIL PROTECTED], you might
> be able to get some better info...
> 
> -- 
> ----------------------------------------------------------------
> |efn Member Service|                           |Patrick R. Wade|
> |Oregon Public Networking / Eugene Free Net|http://www.efn.org/|
> |448 Charnelton St, Eugene, OR 97401 | (541) 484-9637|_________|    
> 

Reply via email to