in reply to Re^2: If conditional checks
in thread If conditional checks
You can use grep instead of the smart match operator (~~):
... if ( grep /^$host$/, @redAlert or ( grep /^$host$/, @orangeAlert and $statusHist01 == 2 ) or $statusHistTot == 3 ) { print "We've got a winner!"; } ...
grep iterates through all array elements, and in scalar context (as in this case), it returns the number of times an expression is true. Each expression in the greps is a regex that requires an exact match between the value of $host and an array element (contained in the default scalar, $_) to be evaluated as true.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: If conditional checks
by kitkit201 (Initiate) on Dec 12, 2012 at 20:13 UTC | |
by Kenosis (Priest) on Dec 12, 2012 at 21:46 UTC | |
by kitkit201 (Initiate) on Dec 13, 2012 at 00:16 UTC | |
by Kenosis (Priest) on Dec 13, 2012 at 00:48 UTC |