http://qs321.pair.com?node_id=258148


in reply to Comparison result capture???

You're assigning the split results to scalars but not using those scalars in the map block, which seems a bit, well, odd. What's up with that?

As for the "last result" idea, foreach (which is spelled "for" by all good monks) will often serve the purpose of avoiding duplicate expressions:

$_ and return $_ for $a_parts[$_] <=> $b_parts[$_];

I've also run into odd restrictions on no strict and I really wish I understood what was broken by accident and what on purpose WRT that.

Finally, I'll take off a fractional style point for using a map block where you really meant foreach....

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
Re: Comparison result capture???
by boo_radley (Parson) on May 14, 2003 at 17:10 UTC
    speaking of odd, your use of for for a 1 element array is pretty novel all in its own right.
      I wish I could say I'd invented that, but I stole it from Tom C. I don't know whether he stole it in turn....

          -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: Re: Comparison result capture???
by dragonchild (Archbishop) on May 14, 2003 at 16:58 UTC
    Didn't you mean
    my $x; ($x = $a_parts[$_] <=> $b_parts[$_]) && return $x for 0 .. $#a_parts;
    You're using $_ too many times.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      I'll grant you that my code uses $_ with more than one meaning, and some people may not like that. But it's clear enough to me. Seems to work, too.

          -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: Re: Comparison result capture???
by shemp (Deacon) on May 14, 2003 at 18:00 UTC
    Oops! I meant to split $a and $b into @a_parts and @b_parts, which makes a lot more sense. I have submitted a change request to the editors.