removing procmail garbage

Discussion in 'Perl' started by surfergirl@thebeach.com, Nov 15, 2006.

  1. Guest

    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.
     
    , Nov 15, 2006
    #1
    1. Advertising

  2. Jim Gibson Guest

    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.
     
    Jim Gibson, Nov 15, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pet Farrari

    Another procmail configuration

    Pet Farrari, Jan 24, 2007, in forum: Perl
    Replies:
    3
    Views:
    2,136
    Randal L. Schwartz
    Jan 28, 2007
  2. Mislav Kasner

    Procmail to ruby

    Mislav Kasner, Nov 5, 2007, in forum: Ruby
    Replies:
    3
    Views:
    206
    Jonathan Hudson
    Nov 6, 2007
  3. J Cardella
    Replies:
    3
    Views:
    192
    Johan Vromans
    Sep 28, 2004
  4. Pet Farrari

    Another procmail configuration

    Pet Farrari, Jan 24, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    125
    Dr.Ruud
    Jan 25, 2007
  5. Horst Lemminger
    Replies:
    1
    Views:
    447
    Dr Eberhard Lisse
    Dec 20, 2011
Loading...

Share This Page