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

Re: [FWP] COBOL as Perl



On Fri, Jul 02, 1999 at 03:06:34PM -0400, Chaim Frenkel wrote:
> *cringe*.
> 
> All typos. In my defense, Your Honor, I can only plead
> That this is a mental template. Which I typed off-the-cuff.

Welllll, I'll let you off with a warning this time :-)  In that case,
I believe this is functionally equivalent:

  $high_value = "\xff" x 80;      # Or whatever

  do {
    $old_left_key = $left_key;

    $left_key = extract_key($left = <LEFT>) 
      unless $left_key gt $right_key;

    $right_key = extract_key($right = <RIGHT>) 
      unless $old_left_key lt $right_key;

    $key = extract_key();   # Do whatever is needed
  } until $left_key eq $high_value && $right_key eq $high_value;

However, while this version looks more "perlish", it's not as
efficient.  There's the temp copy of $left_key, the loop exit test
each time through the loop, and an extra test when $left_key is less
than $right_key.

But at least it looks cool :-)

        Brand

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