in reply to Complex if/else or case logic
Nested code like that is nasty to write correctly, nasty to validate and nasty to maintain. Maybe you can achieve what you want as a two pass thing. Set a bunch of boolean variables to start:
my $isA = $sender eq "sender A"; my $isSpam = $subject =~ /\[SPAM\]/; my $hasSig = $body =~ /^--/; ...
then handle interesting cases as a second stage:
if ($isA && $isSpam && $hasSig) { blowRaspberry($sender); } elsif ($isA && !$isSpam) { sendThankyou(); } ...
which makes new cases much easier to deal with and existing code easy to write and understand.
|
|---|