in reply to Removing Signature from Email

Another solution, which may applied for all those messages that appear NOT to follow the typical /^--/ signature indicator is to read lines from the back of the message up, until you get to a white space line. Then if the last read line (eg the line after the white space) starts with any repeated symbols, such as - or *, it's a good bet that it's a signature. This will err on the side of keeping anything that doesn't look like a sig, even though it might be.
my @message = (<MESSAGE>); my @possible_sig; my $line = pop @message; # Read past white space that may trail message while ( $line =~ /^\s*$/ ) { $line = pop @message; } # Read in what may be the sig... while ( $line !~ /^\s*$/ ) { unshift @possible_sig, $line; $line = pop @message; } # at this point, @message contains the original message, # minus the last 'paragraph' minus trailing whitespace. # @possible_sig contains this last paragraph. # If the first element of @possible_sig does look # like a standard sig, then we just drop it, and @message # is ready to go. Otherwise, just reattach it. if ( $possible_sig[ 0 ] !~ /^[-\*%]{2,}/ ) { push @message, $line; # (put that whitespace back!) push @message, @possible_sig; } # @message can now be written to file.
update: er, code was right, comment was wrong. @possible_sig should be dumped if it looks like a sig.
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain