| > What if I change my name to a symbol (like the artist formerly
| > known as Prince)?
| > 
| > Some ideas for my new name:
| > rm -rf *
| > /dev/null
| > pop @women
| >
| Then you'll be tarred and feathered and run out on a rail. :)

Too much validation in a single regular expression is a bad thing,
since it overcomplicates the regex.  In a real program you'd want
to validate both the name and the email as a seperate function, as
it would probably be checked in several places.

The approach I took reliably extracts the data, but I haven't been
taken over by the validation virus.  However, it'd be easy to see
how to add it:

if (/...regex.../) {
    my ($id, $name, $email) = ($1, $2, $3);

    die "Invalid identifier"
        unless valid_id($id);

    die "Invalid name"
        unless valid_name($name);

    ...
}

To my mind, this approach is a little more verbose - both in terms of quantity of code 
and the
quality of the error reporting.  To make up for the former, it does make it much 
easier to read
than a single regex threatening to wrap around a few times at 79 chars.

TIMTOWTDI

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to