in reply to Multiple testing methods

I think what you need here is an error flag. Do both tests, and if either fails, set the error falg to a true value, then do your print statments based on the value in the error flag. See Below:

my $error = 0; my $message = ''; if($char_keywords > 950){ $error++; $message = "You had $char_keywords chars. Max is 950"; } if(&failrepeattest()){ $error++; $message .= '<br />' if(length($message)); $message .= 'Repeated keyowrd error message.'; } if($error){ print qq(<td><font color="red">Keywords: </font></td>); print qq(<td><font color="red">$message</font><br>); }else{ print qq(<td>Keywords: </td>); }
May the Force be with you

Replies are listed 'Best First'.
Re^2: Multiple testing methods
by BigLug (Chaplain) on Sep 26, 2004 at 21:37 UTC
    I'd go with something similar to the above, but remove some stuff:
    my $message = ''; if ( $char_keywords > 950 ) { $message = "You had $char_keywords chars. Max is 950"; } if ( failrepeattest() ) { $message .= '<br />' if $message; $message .= 'Repeated keyword error message.'; } if ( $message ) { print qq(<td><font color="red">Keywords: </font></td>); print qq(<td><font color="red">$message</font><br>); } else { print qq(<td>Keywords: </td>); }
    You don't need the $error flag. The $message will be empty (false) if there are no errors. I've also taken out the length() check on $message for the same reason .. if the message has length then testing it in this context will return true and the <br> tag will be output.

    Cheers!
    Rick
    If this is a root node: Before responding, please ensure your clue bit is set.
    If this is a reply: This is a discussion group, not a helpdesk ... If the discussion happens to answer a question you've asked, that's incidental.