You need to make your sorts numeric.
[10:09:10.72] P:\test>copy con junk.pl
use strict;
use warnings;
use overload '""'=>'stringify';
sub stringify { $_[0]->() };
sub make_sub {
my ($N) = ( my @f = sort @_ );
return bless sub{ for(;;$N++){ $N % $_ || return $N++ for @f } };
}
@ARGV=(2,3,5) unless @ARGV;
@ARGV=sort @ARGV;
{
local $"=", ";
local $\="\n";
print "Factors: @ARGV";
foreach (@ARGV) {
my $f=make_sub($_);
print "F($_) = @{[($f) x 25]}";
}
my $o=make_sub(@ARGV);
print "R(@ARGV) = @{[($o) x 25]}";
print "----";
}
^Z
1 file(s) copied.
[10:09:30.92] P:\test>junk 3 22 111
Factors: 111, 22, 3
F(111) = 111, 222, 333, 444, 555, 666, 777, 888, 999, 1110, 1221, 1332
+, 1443, 1554, 1665, 1776, 1887, 1998, 2109, 2220, 2331, 2442, 2553, 2
+664, 2775
F(22) = 22, 44, 66, 88, 110, 132, 154, 176, 198, 220, 242, 264, 286, 3
+08, 330, 352, 374, 396, 418, 440, 462, 484, 506, 528, 550
F(3) = 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51
+, 54, 57, 60, 63, 66, 69, 72, 75
R(111, 22, 3) = 111, 114, 117, 120, 123, 126, 129, 132, 135, 138, 141,
+ 144, 147, 150, 153, 154, 156, 159, 162, 165, 168, 171, 174, 176, 177
----
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?