[svn:perlfaq] r8075 - perlfaq/trunk
[email protected] Tue, 14 Nov 2006 17:26:50 -0800 (PST)
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
Author: comdog
Date: Tue Nov 14 17:26:49 2006
New Revision: 8075
Modified:
perlfaq/trunk/perlfaq5.pod
perlfaq/trunk/perlfaq9.pod
Log:
* perlfaq5: All I want to do is append a small amount of text to the end of a file. Do I still have to use locking?
+ updated reference to example in previous answer to say "previous answer"
rather than "above".
* perlfaq9: How do I check a valid mail address?
+ cleansed the code example and joined a few paragraphs.
Modified: perlfaq/trunk/perlfaq5.pod
==============================================================================
--- perlfaq/trunk/perlfaq5.pod (original)
+++ perlfaq/trunk/perlfaq5.pod Tue Nov 14 17:26:49 2006
@@ -801,7 +801,7 @@
If you know you are only going to use a system that does correctly
implement appending (i.e. not Win32) then you can omit the seek() from
-the above code.
+the code in the previous answer.
If you know you are only writing code to run on an OS and filesystem that
does implement append mode correctly (a local filesystem on a modern
Modified: perlfaq/trunk/perlfaq9.pod
==============================================================================
--- perlfaq/trunk/perlfaq9.pod (original)
+++ perlfaq/trunk/perlfaq9.pod Tue Nov 14 17:26:49 2006
@@ -407,6 +407,8 @@
=head2 How do I check a valid mail address?
+(partly contributed by Aaron Sherman)
+
This isn't as simple a question as it sounds. There are two parts:
a) How do I verify that an email address is correctly formatted?
@@ -428,39 +430,30 @@
This I<just> matches the address itself:
- my $atom = qr{[\w!\#$\%&'*+/=?\^`{}~\-]+};
- my $dot_atom = qr{$atom(?:\.$atom)*};
- my $quoted = qr{"(?:\\[^\r\n]|[^\\"])*"};
- my $local = qr{(?:$dot_atom|$quoted)};
+ my $atom = qr{[\w!\#$\%&'*+/=?\^`{}~\-]+};
+ my $dot_atom = qr{$atom(?:\.$atom)*};
+ my $quoted = qr{"(?:\\[^\r\n]|[^\\"])*"};
+ my $local = qr{(?:$dot_atom|$quoted)};
my $domain_lit = qr{\[(?:\\\S|[\x21-\x5a\x5e-\x7e])*\]};
- my $domain = qr{(?:$dot_atom|$domain_lit)};
- my $addr_spec = qr{$local\@$domain};
+ my $domain = qr{(?:$dot_atom|$domain_lit)};
+ my $addr_spec = qr{$local\@$domain};
Just match an address against C</^${addr_spec}$/> to see if it follows
-the RFC2822 specification. However, because it is impossible to be sure
-that such a correctly formed address is actually the correct way to
-reach a particular person or even has a mailbox associated with it, you
-must be very careful about how you use this.
+the RFC2822 specification. However, because it is impossible to be
+sure that such a correctly formed address is actually the correct way
+to reach a particular person or even has a mailbox associated with it,
+you must be very careful about how you use this.
Our best advice for verifying a person's mail address is to have them
-enter their address twice, just as you normally do to change a password.
-This usually weeds out typos. If both versions match, send
-mail to that address with a personal message that looks somewhat like:
-
- Dear [email protected],
-
- Please confirm the mail address you gave us Wed May 6 09:38:41
- MDT 1998 by replying to this message. Include the string
- "Rumpelstiltskin" in that reply, but spelled in reverse; that is,
- start with "Nik...". Once this is done, your confirmed address will
- be entered into our records.
-
-If you get the message back and they've followed your directions,
-you can be reasonably assured that it's real.
+enter their address twice, just as you normally do to change a
+password. This usually weeds out typos. If both versions match, send
+mail to that address with a personal message. If you get the message
+back and they've followed your directions, you can be reasonably
+assured that it's real.
A related strategy that's less open to forgery is to give them a PIN
(personal ID number). Record the address and PIN (best that it be a
-random one) for later processing. In the mail you send, ask them to
+random one) for later processing. In the mail you send, ask them to
include the PIN in their reply. But if it bounces, or the message is
included via a "vacation" script, it'll be there anyway. So it's
best to ask them to mail back a slight alteration of the PIN, such as