In preference toif( $var1 == 1 ) { if( $var2 == 2 ) { doSomething(); } }(would you?).if( $var1 == 1 && $var2 == 2 ) { doSomething(); }
Actually, I quite often find that the first of these two is exactly what I want as it makes what I'm doing much more clear. Othertimes, I use the latter. It really depends on whether the two tests are related or not, as well as whether there are other things I want to do in the $var==1 case but only if $var2!=2.
So I often find myself writing a grep of a grep. Or a grep of a map of a map of a grep. Or a map of a grep of a grep. Or ... when a single map may just do fine.
Your first example, having two if's to check the same thing, isn't really analogous to combining grep's since each grep is checking different things.
In reply to Re^5: Automatically add all defined functions to your @EXPORT
by Tanktalus
in thread Automatically add all defined functions to your @EXPORT
by merlyn
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |