# check for missing fields
if (!$var1) {
return 'missing_var1';
} elsif (!$var2) {
return 'missing_var2';
} elsif (! $hash->{val1}) {
return 'missing_hash_val1';
} elsif (! $hash->{val2}) {
return 'missing_hash_val2';
} elsif (! $hash->{val3}) {
return 'missing_val3';
} elsif (! $hash->{val4}) {
return 'missing_hash_val4';
} elsif (! $hash->{val5}) {
return 'missing_hash_val5';
} elsif (! $hash->{val6}) {
return 'missing_hash_val6';
} elsif (! $hash->{val7}) {
return 'missing_hash_val7';
} elsif (! $hash->{val7}) {
return 'missing_hash_val8';
} elsif (! $hash->{val9}) {
return 'missing_hash_val9';
} elsif (! $hash->{val10}) {
return 'missing_hash_val10';
} elsif (!$var3) {
return 'missing_var3';
} elsif (!$var4) {
return 'missing_val4';
}[identifiers changed to protect the innocent, but otherwise this is verbatim]
Gee, I wonder if this could be simplified? I really don’t see the pattern…
Sadly, I see code like this much to often. Most of the time it’s old and the developer(s) moved on long ago. I stopped reading TheDailyWTF regularly because it hits too close to home nowadays.