Date: Mon, 04 Jan 2016 14:15:14 +0100 From: =?UTF-8?Q?Sol=C3=A8ne_Rapenne?= <solene@bsd.zplay.eu> To: Matthias Apitz <guru@unixarea.de>, freebsd-questions@freebsd.org, pdw@ex-parrot.com Cc: owner-freebsd-questions@freebsd.org Subject: Re: ports/p5-Mail-RFC822-Address does not work as expected/described Message-ID: <626864349e1a3c422fdd2389275537fd@mail.zplay.eu> In-Reply-To: <20160104124926.GA4417@c720-r285885-amd64> References: <20160104124926.GA4417@c720-r285885-amd64>
next in thread | previous in thread | raw e-mail | index | archive | help
Le 2016-01-04 13:49, Matthias Apitz a écrit :
> Hello,
>
> I installed from the ports the port p5-Mail-RFC822-Address to verify
> mail addrs against RFC822; the example code provided by the author is:
>
>
> #!/usr/local/bin/perl
>
> use Mail::RFC822::Address qw(valid validlist);
>
> if (valid("pdw@ex-parrot.com")) {
> print "That's a valid address\n";
> }
>
> if (validlist("pdw@ex-parrot.com, other@elsewhere.com")) {
> print "That's a valid list of addresses\n";
> }
>
> But I can only manage to get this working when doing the test as
>
> if (valid("pdw@ex-parrot.com") == true) {
> ...
>
> Why is this? I'm by no means a Perl expert :-)
>
> Thx
>
> matthias
Hello,
I tried the following :
#!/usr/bin/env perl
use Mail::RFC822::Address qw(valid validlist);
if (valid("test@ex-parrot.com")) {
print "valid\n";
} else { print "not valid\n"; }
this return "not valid"
You shoud always add the following on the top of your perl scripts :
use stict;
use warnings;
When you add the 2 uses, then you get an error with the example :
Possible unintended interpolation of @ex in string at ./test.pl line 7.
Global symbol "@ex" requires explicit package name at ./test.pl line 7.
Execution of ./test.pl aborted due to compilation errors.
If you use simple quotes then, you will have the "valid" message.
By using double quotes, I think it tries to call @ex array which is not
what you want.
Maybe the example used to work with some perl version, or it is
something else I don't know, but as this, the example doesn't work.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?626864349e1a3c422fdd2389275537fd>
