Hi all, i was working on a function to sort ip like strings, and ran into a couple of odd things. Well, here is the sort function - it could be done differently i know, but it shows my situation:
use strict; ... sub ip_sorter {
    my $a_parts = split /\./, $a;
    my $b_parts = split /\./, $b;
my @a_parts = split /\./, $a; my @b_parts = split /\./, $b; my $result; map { return $result if $result = ($a_parts[$_] <=> $b_parts[$_]) +} (0 .. $#a_parts);
so, 1 issue i had was that i couldnt put "no strict" in the map block. I dont know why this is, any insight would be great.

Also, i was unable to find any variable that perl implicitly sets as the result of a comparison. Im thinking something analogous to $! - the value of C errno. So lets just pretend that $^C gets set to the result of the last comparison operation. then i could rewrite my sort with this line:
... map { return $^C if ($a_parts[$_] <=> $b_parts[$_]) }; ...
I've looked for this variable at search.cpan.org/author/JHI/perl-5.8.0/pod/perlvar.pod to no avail.

Fixed typo at author's req - dvergin 2003-05-14


In reply to Comparison result capture??? by shemp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.