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

Re: [FWP] do... while?



"Edward M. Perry" wrote:

> >
> > You can tell from the prefixes where this code comes from :-)
> >
> >               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 );
> >               }
> >     }
> >
> >
> > Once again, operating under the Principle of Making the Goal Clear to the
> > Reader... I share an example of what (IMHO :) not to do.
> >
> > Anybody with me on _why_? ;)
>
> The intent wasn't too bad, but the execution was indeed poor.
> Once simplified, it makes for solid, readable code.
> I use this a lot. Now about those variable names...
>
> while (!$bFound && @aListOfOldAceFiles) {
>    $szOldAceFile = shift @aListOfOldAceFiles;
>    $bFound = bCheckIfThisIsAnAceFile($szOldAceFile)
> }

I find this to be more readable still:

     foreach(@aListOfOldAceFiles) {
         last if $bFound = bCheckIfThisIsAnAceFile($_);
     }

- Borup


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe