Shaun, You would want to use a switch (sometimes called "case") statement....try something like this
MYSWITCH: for ($something) { /string0/&& do { &do_something; last MYSWITCH; }; /string1/&& do { &do_something; last MYSWITCH; }; /string2/&& do { &do_something; last MYSWITCH; }; #Default case warn "None of the cases matched....doing something else"; &do_something_else; } I realize this is the long way to go about it, and it could be done in less code, but I wanted to show you how to use a switch statement. In this case I'd suggest just using the "|" in your regex.....like below if( $something =~ /(string0|string1|string2)/) { &do_something; } else { &do_something_else; } Hope this helps, Kevin On Tuesday 23 April 2002 04:15 pm, Shaun Fryer wrote: > Is there a simple way to evaluate multiple conditions in an if or > unless statement? For example take the following very simple example. > > if (($something eq 'string0') || ($something eq 'string1') || ($something > =~ /string2/)) { &do_something; > } else { > &do_somthing_else; > } > > Being a bit of a spartan I think it would be nice if I could do it > like the following instead. > > if ($something eq ('string0' || 'string1' || =~ /string2/)) { > &do_something; > } else { > &do_somthing_else; > } > > But the latter doesn't seem to work. So, as a kluge I've been doing as > follows. > > my $test_ok; > $test_ok = 1 if ($something eq 'string0'); > $test_ok = 1 if ($something eq 'string1'); > $test_ok = 1 if ($something =~ /string2/); > if ($test_ok) { > &do_something; > } else { > &do_somthing_else; > } > > Is there a better way to simplify the syntax when testing for multiple > conditions? > > =================== > Shaun Fryer > =================== > London Webmasters > http://LWEB.NET > PH: 519-858-9660 > FX: 519-858-9024 > =================== -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]