I get the warning when $a or $b is 'etc' or "ccp". and it seems to be tied to the two lines I commented on. The if statement above them does not cause any problems, but I assume that's because neither site has any numbers in them(?). Is there something I can do to eliminate the warnings or can I just ignore them (and add a no warnings numeric)? Using Perl 5.16.3.
my %site = ( 24j1 => { count=>1, devices=>['192.168.0.1'] }, 1924 => { count=>3, devices=>['192.168.1.1','192.168.1.3','192 +.168.1.9'] }, etc => { count=>2, devices=>['192.168.2.1','192.168.2.23'] }, ccp => { count=>1, devices=>['192.168.3.1'] }, ); sub my_sort { if( ("$a" ~~ @datacenters) && ("$b" ~~ @datacenters) ) { return $site{$b}->{count} <=> $site{$a}->{count}; } if( ("$a" ~~ @datacenters) && ! ( "$b" ~~ @datacenters) ) { retu +rn $a } # Warnings go away if I if( ("$b" ~~ @datacenters) && ! ( "$a" ~~ @datacenters) ) { retu +rn $b } # comment out these two lines. if( ( $a =~ $eu_regex ) && ( $b !~ $eu_regex ) ) { retu +rn $a } if( ( $b =~ $eu_regex ) && ( $a !~ $eu_regex ) ) { retu +rn $b } return $site{$b}->{count} <=> $site{$a}->{count}; } foreach my $site ( sort my_sort keys %site ) {do_stuff_with($site) }

Elda Taluta; Sarks Sark; Ark Arks
My deviantART gallery


In reply to Argument isn't numeric in sort -- resolve or ignore? by Argel

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.