Bass-Fighter has asked for the wisdom of the Perl Monks concerning the following question:

hi monks,

I have a bit of a silly question:
I have the the "to" from an email...
If I get this with my code the value variates.
this are some options:
name<email>, like "Michiel van der Maas<>" (that is my email)
<email>, like <>"
and there are more...
but I only want the email without the tags, so I can equalize it with email adresses in a database. first I thought, I can get this with some substr's. but everytime the adress has another length, so what is the best option to get it? because I can't see it this moment...

Replies are listed 'Best First'.
Re: mailadress splitten.
by davido (Cardinal) on Jan 20, 2009 at 07:59 UTC

    Don't bother trying to roll your own email address parser. It's a lot more complicated than it would seem at first blush.

    use Email::Address; my @addresses = Email::Address->parse($line);

    (Example taken from the Email::Address documentation.) Just search cpan for it.



      It worked, thanks alot, without that module it is more difficult than I expected.

      I haven't thought about that module actually, thanks, I think I can get it with this
Re: mailadress splitten.
by ChOas (Curate) on Jan 20, 2009 at 08:03 UTC
    Something like this ? :
    my @email=($to=~/<([^>]+)>/gs);


    print "profeth still\n" if /bird|devil/;
      it could be... but if I copy that code in my program, I get this error:
      Use of uninitialized value in pattern match (m//)
        define $to Bass