ports/p5-Mail-RFC822-Address does not work as expected/described
Solène Rapenne
solene at bsd.zplay.eu
Mon Jan 4 13:15:28 UTC 2016
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 at ex-parrot.com")) {
> print "That's a valid address\n";
> }
>
> if (validlist("pdw at ex-parrot.com, other at 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 at 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 at 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.
More information about the freebsd-questions
mailing list