If statements inside or outside loops?

Posted by Timmy on Stack Overflow See other posts from Stack Overflow or by Timmy
Published on 2010-02-11T04:18:09Z Indexed on 2010/05/25 4:31 UTC
Read the original article Hit count: 143

Filed under:
|

Is it better if I do this:

foreach my $item ( @array ) {
   if ( $bool ) {
     .. code ..
   }
   else {
     .. code ..
   }
}

or

if ( $bool ) {
   foreach my $item ( @array ) {
   }
}
else {
   foreach my $item ( @array ) {
   }
}

© Stack Overflow or respective owner

Related posts about perl

Related posts about optimization