假设我的IPvN是一个格式与IPv4几乎相同的序列,唯一的区别是可以有任意数量的点或数字.我想按如下方式对这些序列列表进行排序.
8.8.8.8
20.0.0.0
1.2.3.4.5
Run Code Online (Sandbox Code Playgroud)
我用粗糙的方法来合成逻辑条件表达式.我知道这样做是非常低效和浪费内存,特别是当只有少数异常长的IPvN时,人们可以一眼就解决但我拖着完全冗余和无用的代码尾巴,如... or $a->[1000] <=> $b->[1000].
正如你在下面看到的,我做了一个叠加的双层Schwartzian变换.
(我输出的第一行.)
Use of uninitialized value in numeric comparison (<=>) at (eval 4) line 1.
Run Code Online (Sandbox Code Playgroud)
但是,如果它是
'8.8.8.6.0' => 6不是
'8.8.8.8.0' => 6在%IP_counter,不会有任何警告.
我只知道这个错误与此有关
'8.8.8.8' => 3.
use strict;
use warnings;
use feature 'say';
use List::Util qw(max);
my %IP_counter =
(
'1.1.1.1.1' => 1,
'127.0.0.1' => 2,
'8.8.8.8' => 3,
'20.0.0.1' => 4,
'999999999999999999999999999999999999999999999999.9'
=> 5, …Run Code Online (Sandbox Code Playgroud)