Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

mailadress splitten.

by Bass-Fighter (Beadle)
on Jan 20, 2009 at 07:38 UTC ( #737497=perlquestion: print w/replies, xml ) Need Help??

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<michiel_masterm@hotmail.com>" (that is my email)
<email>, like <michiel_masterm@hotmail.com>"
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.


    Dave

      !UPDATE!

      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);

    GreetZ!,
      ChOas

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://737497]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2019-06-17 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (80 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!