From owner-freebsd-questions@freebsd.org Mon Jan 4 13:15:28 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B6FCA60C36; Mon, 4 Jan 2016 13:15:28 +0000 (UTC) (envelope-from solene@bsd.zplay.eu) Received: from bsd.zplay.eu (bsd.zplay.eu [62.210.240.224]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "bsd.zplay.eu", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id E9CD41A69; Mon, 4 Jan 2016 13:15:27 +0000 (UTC) (envelope-from solene@bsd.zplay.eu) Received: from localhost (bsd.zplay.eu [local]) by bsd.zplay.eu (OpenSMTPD) with ESMTPA id 9aca7bb7; Mon, 4 Jan 2016 14:15:15 +0100 (CET) To: Matthias Apitz , freebsd-questions@freebsd.org, pdw@ex-parrot.com Subject: Re: ports/p5-Mail-RFC822-Address does not work as expected/described X-PHP-Originating-Script: 0:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 04 Jan 2016 14:15:14 +0100 From: =?UTF-8?Q?Sol=C3=A8ne_Rapenne?= Cc: owner-freebsd-questions@freebsd.org In-Reply-To: <20160104124926.GA4417@c720-r285885-amd64> References: <20160104124926.GA4417@c720-r285885-amd64> Message-ID: <626864349e1a3c422fdd2389275537fd@mail.zplay.eu> X-Sender: solene@bsd.zplay.eu User-Agent: Roundcube Webmail/1.1.3 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jan 2016 13:15:28 -0000 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.