in reply to preventing malicious mail attacks

No need to use a reg-ex where good'ol split will do:

use strict; use warnings; my $emailaddress='xung03@aol.com To: xung03@aol.com From: xung03@aol.c +om Subject: Hog(DA913529,email) JmW yB Q eoP . => xung03@aol.com To: +xung03@aol.com From: xung03@aol.com Subject: Yq(DA913529,name)RiatdJ +VoyY41ILqAdOjfxkvfKaH8JMobcYw . ::xung03@aol.com To: xung03@aol.com F +rom: xung03@aol.com Subject: 9joI(DA913529,add1)e6WS1maM J . ::xung03 +@aol.com To: xung03@aol.com From: xung03@aol.com Subject: U84QoU(DA91 +3529,add2)wIfhxuNg 97ob4Cn3k0VauKEoM74hIYt . ::xung03@aol.com To: xun +g03@aol.com From: xung03@aol.com Subject: qI6(DA913529,city) XN8s Akd + xjLmZqTf0s15E4688jkblKj . ::xung03@aol.com To: xung03@aol.com From: +xung03@aol.com Subject: (DA913529,zip)Pxia 3i HvHE0tfDHxxSf0CF6W Kyi0 +WHeieL BZBAFcszbJGEgO1ha::'; my ($good_address, $rubbish) = split /[ ,]/, $emailaddress, 2; print $good_address;

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re: Re: preventing malicious mail attacks
by Anonymous Monk on Feb 01, 2004 at 19:04 UTC
    Okay, I'll try your code in a minute..it seems like I have more than just that problem. I can't find a way to delete that key!

    The key is:

    xung03@aol.com To: xung03@aol.com From: xung03@aol.com Subject: Hog(DA +913529,email) JmW yB Q eoP .
    I tried:
    delete $emails{"xung03\@aol\.com To\: xung03\@aol\.com From\: xung03\@ +aol\.com Subject\: Hog\(DA913529\,email\) JmW yB Q eoP \."};
    And:
    delete $emails{"xung03@aol.com To: xung03@aol.com From: xung03@aol.com + Subject: Hog(DA913529,email) JmW yB Q eoP ."};
    But the silly infected hash key/value won't leave lil' me alone :(
      You don't have to escape "funny" characters in a hash key.

      Are you sure the key is correct? No trailing spaces or so? What error message do you get when you try to delete this key (in other words how do you know the key was not deleted)?

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

        I'm using:
        delete $emails{'xung03@aol.com To: xung03@aol.com From: xung03@aol.com + Subject: Yq(DA913529,name)RiatdJ VoyY41ILqAdOjfxkvfKaH8JMobcYw .'}; foreach (keys %emails) { print "$_ => $emails{$_}<br>"; }
        I'm printing all the keys/values AFTER I try to delete it, but that key just doesn't go away. as you can see through my print, the => is my separator between the hash key and it's value. That means that everything before the => is the key and that's what I'm trying to get rid of.