[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] do... while?



On 2 Jul 99, at 14:33, Vicki Brown wrote:

>   my $bContinueLooking = 1;
>   do {
>       if ( $#aListOfOldAceFiles == -1 ) {
>         $bTransferTags = 0;
>         $bContinueLooking = 0;
>       }
>       else {
>         $szOldAceFile = shift @aListOfOldAceFiles;
>         $bIsAnAceFile = &bCheckIfThisIsAnAceFile( $szOldAceFile );
>         if ( $bIsAnAceFile ) {
>           $bTransferTags = 1;
>           $bContinueLooking = 0;
>         }
>       }
>     } while( $bContinueLooking );
>   }
>     }

Not the clearest code to figure out what it's doing, but if i have it 
right, that's a circumstance where in a bygone era I'd use a GOTO [and 
indeed, I _still_ think it is the clearest flow-of-control construct, but 
I've been bludgeoned into using 'last <BLOCK>'].  My general idiom for 
something like this would be:

   my $foundanAceFile = 0;
SEARCH:
   foreach (@ListOfOldAceFiles)
   {
      $foundanAceFile = 1, last SEARCH
         if &CheckIfThisIsAnAceFile( $_ );
   }

Is that about right?  or have I [again..sigh] missed the point..:o)

   /bernie\      
-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:bernie@fantasyfarm.com     Pearisburg, VA
    -->  Too many people, too few sheep  <--          

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org