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

Re: [FWP] do... while?




On Mon, 5 Jul 1999, Edward M. Perry wrote:

> 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)
> }

foreach my $oldfile (@oldfiles) {
  ($found=1,last) if isacefile($oldfile);
}

Haven't tested it, but that would be okay, right? It feels more Perlish to
me. I haven't looked at the original code; all that Windows stuff brought
back some painful memories, and I averted my eyes.

Actually, if the "if ($found) {...}" construct was short enough, I might
have been tempted to combine all that crud into:

foreach my $oldfile (@oldfiles) {
  if (isacefile($oldfile) {
    # stuff
    last;
  }
}

I really don't know why someone would want to mangle the array in this
kind of loop, with the shift stuff. It might even perform worse than a
foreach...


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