## check to see if username or email already exist 
($errmesseml, $errmessuser, $emailuserfound) = "False";
$errmesseml = "True" if ($dbemail eq $email); 
$errmessuser = "True" if ($dbusername eq $membusrname);
        
## create readable error message
$errmessage = undef;
($errmesseml eq "True")?(($errmessuser eq "True")?($errmessage="Both the
email address and the username have already been
used",$emailuserfound="True"):($errmessage="The email address has already
been used",$emailuserfound="True")):(($errmessage="The username has already
been used",$emailuserfound="True") if $errmessuser eq True);
__END__


Or a more readable way:
## create readable error message
if ($errmesseml eq "True") {
  if ($errmessuser eq "True") {
    $errmessage = "Both the email address and the username have already been
used";
    $emailuserfound = "True";
  } else {
    $errmessage = "The email address has already been used";
    $emailuserfound = "True";
  }
} else {
  if ($errmessuser eq True) {
    $errmessage = "The username has already been used"
    $emailuserfound = "True"
  }
}
__END__

-----Original Message-----
From: Anadi Taylor [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 03, 2003 12:51 PM
To: [EMAIL PROTECTED]
Subject: is there a 'more perl' way of doing this


Hi all,
I have to start by thanking you all for your help so far - its been 
invaluable. If it were'nt for you guys and gals i would have pulled my hair 
out by now !!!!!

OK - here is the thing: I have written some code and it works fine 
(yahoooo), but i was wondering if there is a more 'PERL' way of doing things

as this code looks bulky to me !!!!

the code id:

## check to see if username or email already exist

        $errmesseml     = "False";
        $errmessuser    = "False";
        $emailuserfound = "False";

        if($dbemail eq $email)
        {
                $errmesseml = "True";
        }

        if($dbusername eq $membusrname)
        {
                $errmessuser = "True";
        }

## create readable error message

        $errmessage = "";

        if (($errmesseml eq "True") and ($errmessuser eq "True"))
        {
                $errmessage = "Both the email address and the username have
already been 
used";
                $emailuserfound = "True";

        }

        if (($errmesseml eq "True") and ($errmessuser ne "True"))
        {
                $errmessage = "The email address has already been used";
                $emailuserfound = "True";
        }

        if (($errmesseml ne "True") and ($errmessuser eq "True"))
        {
                $errmessage = "The username has already been used";
                $emailuserfound = "True";
        }



I have tried to use lines like:

if ($errmesseml and !($errmessuser)) { do something }

but it doesnt work !!!! A bit of a bummer really - any ideas ?????


Thanks again

Anadi


_________________________________________________________________
Chat online in real time with MSN Messenger http://messenger.msn.co.uk


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

Reply via email to