> Can anyone confirm if I understand this right:
> 
> if ( $username =~ /@/ )
> {
>    $_ = $username;
>    ($username) = /(.*)\@/;
> }
> 
> The part
>   ($username) = /(.*)\@/; 
> removes the @ symbol?

Yes, but what if you've got two @'s?  ;-)

The two lines in the 'if' can be rewritten as:

$username =~ /(.*)\@/;

The 'if' test is almost redundant, as we are sending the
same data through both regexps.  Unless finding '@' is an
exceptional case then this will be slower than creating a
"better regexp".  Try these three:

  ($username) = split '@', $username;

Easy to read, but slow since we split '[EMAIL PROTECTED]' into
'foo' and 'bar.com'... even though we discard the second
one.

($username) =~ /^(.*?)\@?/;

Needs testing, since it *might* be broken.  I think (.*?)
would match everything including any @.

  $username =~ s/\@.*//;

If $username was several thousand characters long this
would take my fancy.

> Does it do anything else?

Not AFAIK

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