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) }
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.