Reputation: 25986
To me this code is how I think of the problem I want to solve
if ($b eq "" && $ok) {
} elsif ($b eq "" && !$ok) {
print "ERROR1\n";
} else {
print "ERROR2\n";
}
but it is not very pretty I suppose having an empty if
-statement.
Are there ways to avoid this?
Upvotes: 2
Views: 256
Reputation: 2604
Keeping the if, but checking $b
if ($b eq "") {
if (!$ok) {
print "ERROR1\n";
}
}
else{
print "ERROR2\n";
}
Upvotes: 5
Reputation: 944
You just need to change the logic to what you want
if($b eq "" && !$ok){
print "ERROR1\n";
}elsif( !$ok || $b ne ""){
print "ERROR2\n";
}
Upvotes: 3