Ok, here's an example to start you thinking.
[tt]
#!/usr/bin/perl -w
use strict;
my $attachment_file = shift
or die "I need the attachment filename on the command line please\n";
while(<>){
next unless /Start of attachment/;
open(F,$attachment_file) || die "can't write file $!\n";
while(<>){
last if /End of attachment/;
print F $_;
}
close(F);
}
[/tt]
The logic of the script runs like this:
Read through the mail until I find the string that marks the begininning of an attachment.
Open a file to store the attachment.
Print each line from the mail into the attachment file, until I find the string that marks the end of an attachment.
Close the attachment file.
You with me? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.