On Fri, Jun 18, 2004, JJB wrote:
>I have this
>
>
>      #("Scan line for word abuse,");
>
>      if ((/([EMAIL PROTECTED])\s/) || (/([EMAIL PROTECTED])\s/))
>      {
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]"") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]"") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if ((${1} =~ /[EMAIL PROTECTED]/i) || (${1} =~ /[EMAIL PROTECTED]/i))
>       {
>        next;
>       }
>       else
>       {
>        $abuse_email = ${1};
>        debug("abuse_email body = $abuse_email\n");
>       }
>      }
>
>How can I rewrite the
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]>") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]"") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>       if (${1} eq "[EMAIL PROTECTED]"") { $abuse_email =
>"[EMAIL PROTECTED]"; next; }
>
>part so I can check the last position of what ever is found for > \
>/ ) } ] and delete those unwanted characters from value that gets
>loaded into $abuse_email???

This type of thing is generally better handled using a hash for
the test, something like:

# This just loads 1 into the hash for each address.  One might
# want to generalize by mapping to the real abuse address.
my %addrmap = map { $_, 1 } qw(
        [EMAIL PROTECTED] 
        [EMAIL PROTECTED]
        [EMAIL PROTECTED]
        [EMAIL PROTECTED]
        [EMAIL PROTECTED]
        [EMAIL PROTECTED]
);

# $1 will be all no-whitespace after the ``@''
if(/abuse\@(\S+) && $addrmap{$1) {
        ($abuse_email = $1) =~ s/>*$//; # strip trailing '>'(s)
}
...

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``Virtually everything is under federal control nowadays except the
federal budget.''
    -- Herman E. Talmadge, 1975
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to