Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - removing procmail garbage

 
Thread Tools Search this Thread
Old 11-15-2006, 07:45 AM   #1
Default removing procmail garbage


How can I use perl to remove garbage in my mailbox
caused by my procmail filter. This is a known problem
but it occurs too frequently and I certainly don't want
to give up procmail. What I get is a false message
like this:

From foo@bar Tue Nov 14 21:26:34 2006


so I need a one-line perl script to remove the line(s)
from my inbox before I read mail as in:

cat $inbox |perl -pi -e 's/^From foo@bar//g'

However, that will not work since sometimes the
"^From " line could be followed by a "Status:" or other lines.
Thus, the removal must do a range as in awk ala:

cat $inbox |awk '/^From foo@bar/,/^$/' {next} 1

This however does not work for me either and I'm not sure why
other than my awk being from Solaris 7.

Thanks for your help.


surfergirl@thebeach.com
  Reply With Quote
Old 11-15-2006, 05:11 PM   #2
Jim Gibson
 
Posts: n/a
Default Re: removing procmail garbage

In article <WAz6h.1016$>, <>
wrote:

> How can I use perl to remove garbage in my mailbox
> caused by my procmail filter. This is a known problem
> but it occurs too frequently and I certainly don't want
> to give up procmail. What I get is a false message
> like this:
>
> From foo@bar Tue Nov 14 21:26:34 2006
>
>
> so I need a one-line perl script to remove the line(s)
> from my inbox before I read mail as in:
>
> cat $inbox |perl -pi -e 's/^From foo@bar//g'
>
> However, that will not work since sometimes the
> "^From " line could be followed by a "Status:" or other lines.
> Thus, the removal must do a range as in awk ala:
>
> cat $inbox |awk '/^From foo@bar/,/^$/' {next} 1
>
> This however does not work for me either and I'm not sure why
> other than my awk being from Solaris 7.


I am not familiar with awk operations, so cannot be sure, but you might
be able to use the Perl 'flip-flop' operator (e.g., /^From/ .. /^$/).
See 'perldoc perlop' and search for 'Range Operators'.

FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future.
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump