Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simple problem with Email::Address

0 views
Skip to first unread message

Bernie Cosell

unread,
May 16, 2008, 1:37:08 PM5/16/08
to
I'm trying to parse an email address and I can't seem to get Email::Address
to work quite.

#!/usr/bin/perl

use strict;
use warnings ;
use Email::Address ;

my $addr = "My Name <myname\@verizon.net>\n" ;
my @addrs = Email::Address::parse($addr) ;
warn scalar(@addrs) ;

Gets me "0" -- it appears not to parse that string, which certainly looks
like a legal email addr to me [am I missing some problem with it?? -- I
actually pulled it out of a file of addresses that sendmail is happily
sending-via]. What am I missing here? THANKS!

/bernie\
--
Bernie Cosell Fantasy Farm Fibers
ber...@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--

comp.llang.perl.moderated

unread,
May 16, 2008, 3:08:51 PM5/16/08
to
On May 16, 10:37 am, Bernie Cosell <ber...@fantasyfarm.com> wrote:
> I'm trying to parse an email address and I can't seem to get Email::Address
> to work quite.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings ;
> use Email::Address ;
>
> my $addr = "My Name <myname\@verizon.net>\n" ;
> my @addrs = Email::Address::parse($addr) ;
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Email::Address->parse($addr);

--
Charles DeRykus

Jim Gibson

unread,
May 16, 2008, 3:09:25 PM5/16/08
to
In article <aahr24dpblvs36fuh...@library.airnews.net>,
Bernie Cosell <ber...@fantasyfarm.com> wrote:

> I'm trying to parse an email address and I can't seem to get Email::Address
> to work quite.

You are not calling parse() correctly.

>
> #!/usr/bin/perl
>
> use strict;
> use warnings ;
> use Email::Address ;
>
> my $addr = "My Name <myname\@verizon.net>\n" ;
> my @addrs = Email::Address::parse($addr) ;

my @addrs = Email::Address->parse($addr);

> warn scalar(@addrs) ;
>
> Gets me "0" -- it appears not to parse that string, which certainly looks
> like a legal email addr to me [am I missing some problem with it?? -- I
> actually pulled it out of a file of addresses that sendmail is happily
> sending-via]. What am I missing here? THANKS!

perldoc Email::Address

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
http://www.usenet.com

ber...@fantasyfarm.com

unread,
May 16, 2008, 3:17:25 PM5/16/08
to
On May 16, 3:08 pm, "comp.llang.perl.moderated" <c...@blv-

Thanks! Total brain cramp... I _thought_ I had cut/pasted the call
to parse from the E::A man page but obviously I screwed up bigtime
[and it was one of those dumbnesses that after-the-fact you can't see
in your own code]. THANKS!!

/Bernie\

A. Sinan Unur

unread,
May 16, 2008, 3:21:51 PM5/16/08
to
Bernie Cosell <ber...@fantasyfarm.com> wrote in
news:aahr24dpblvs36fuh...@library.airnews.net:

> I'm trying to parse an email address and I can't seem to get
> Email::Address to work quite.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings ;
> use Email::Address ;
>
> my $addr = "My Name <myname\@verizon.net>\n" ;
> my @addrs = Email::Address::parse($addr) ;

parse is a class method.


C:\Temp> cat x.pl
#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;
use Email::Address;

my $in = "My Name <myname\@verizon.net>";
print Dumper ( Email::Address->parse($in) )

__END__

C:\Temp> x
$VAR1 = bless( [
'My Name',
'myn...@verizon.net',
'',
'My Name <myn...@verizon.net>',
[
\'My Name <myn...@verizon.net>',
'0'
]
], 'Email::Address' );

Sinan

--
A. Sinan Unur <1u...@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/

0 new messages