in reply to comparing multiple arg values against multiple files
However, if your array is sizable (or if you are iterating over this construct, using grep is not a good idea. grep forces you to check every value in @ARRAY, but a foreach loop can be exited as soon as a match is found, thus being more efficient.$x = 3; $y = 7; @array = ( 0, 3, 7 ); if ( grep { $_ == $x } @array and grep { $_ == $y } @array ) { print "Good\n"; } else { print "Bad\n" }
Update: I tossed this code out quickly, so I realize that I may not have gotten the full intent of what you wanted. You mentioned three arg values (I missed that at first), but then went on to state that there are things you want to do if the first two args evaluate as true. Is the third arg value even relevant to your question? I'm missing something here. If it's not relevant, then I think my snippet answers your question. Otherwise, could you clarify?
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
|
|---|