However, unfortunately, I do not have sufficient permissions to install
modules other than in external directories on the server.
The Email::Valid module is not a problem as it can be installed by ...
perl Makefile.PL PREFIX=/where/I/want/it/put
... but the installation of MailTools-1.74 does not offer the same
possibility through the PREFIX method. I tried but I got the usual error:
"Warning: You do not permission to install in /usr/lib/perl5/.." etc.
Anyone happens to know a solution? Or perhaps better, a procedure that is
already part of the perl version which I have - perl 5.6.1.
What I'm hoping for is a non-critical address syntax check, without getting
my hands dirty with complex regex's and RFC's....
Any pointers to man pages, or even entire syntax checking code, would be
greatly appreciated!
Many thanks!
[...]
> Any pointers to man pages, or even entire syntax checking code, would be
> greatly appreciated!
To be a bit more specific in terms of the conditions I would like to check
and what I consider valid form input, that is: one or more comma or white
space separated valid email addresses.
What I do not need or plan to make use of are live checks that query smtp
servers for existence of addresses, as I understand such type of procedures
do not necessarily work, nor could they speed up the cgi processing.
I'm using this sub in a couple of applications:
sub emailsyntax {
return 1 unless my ($localpart, $domain) = shift =~ /^(.+)@(.+)/;
my $atom = '[^[:cntrl:] "(),.:;<>@\[\\\\\]]+';
my $qstring = '"(?:\\\\.|[^"\\\\\s]|[ \t])*"';
my $word = qr($atom|$qstring);
return 1 unless $localpart =~ /^$word(?:\.$word)*$/;
$domain =~ /^$atom(?:\.$atom)+$/ ? 0 : 1;
}
my $address = 'john....@example.com';
print "Syntax ok\n" unless emailsyntax($address);
It's not as strict as RFC 822; for instance it accepts non-ASCII
characters. Still catches most syntactical typos.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
> ... but the installation of MailTools-1.74 does not offer the same
> possibility through the PREFIX method. I tried but I got the usual error:
> "Warning: You do not permission to install in /usr/lib/perl5/.." etc.
Recheck the FAQ on this, which refers to LIB as well as PREFIX.
Regards,
Chris
[...]
> It's not as strict as RFC 822; for instance it accepts non-ASCII
> characters. Still catches most syntactical typos.
Many thanks for this contribution - I will test and hopefully it will fit my
purpose perfectly!
You're welcome.
> - I will test and hopefully it will fit my purpose perfectly!
Please let me know of possible findings.
> Please let me know of possible findings.
Thanks. But I can't quite see through this. I get a perl syntax error
near "=~ ^".
Any chance that you could kindly post your complete script within a
cut-n-paste example for the blind and stupid?
Many thanks!
But... The code I posted _is_ intended to copy, paste and run. Your
newsreader must have done something with it.
Try to copy from:
http://groups.google.com/group/comp.lang.perl.modules/msg/e7e65ccea8c2fac9
[..]
> newsreader must have done something with it.
Yes - some of the forward slashes were gone. Damn newsreader! If I view
source they are all there and your script works fine - thanks again!