perlquestion
cunningrat
<p> Disclaimer: I'm not a perl monk. Oblate, at best.</p>
<p> I'm writing a subroutine to parse a mail message according to multiple criteria, and figure out what "kind" of message it is. The criteria can be message senders, presence of particular text in the subject line, or presence of particular text in the body of the email.</p>
<p> The obvious way to do it is a very, very complex block of nested if/else's. Is there a better way to do it?</p>
<p> Example pseudocode: </p>
<code>
if ($sender = "sender A")
{
if ($subject =~ "some text")
{
if ($body =~ "some other text")
{ return "type 1"; }
elsif ($body =~ "some other other text)
{return "type 2"; }
else {return "type 3";}
}
elsif ($subject =~ "some other subject")
...
</code>
<p> You get the idea. </p>