while($line = <$in_fh>) { chomp $line; if ($line =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)/) { $a = $1; $b = $2; $c = $3; $d = $4; $ip = "$a.$b.$c.$d"; $classc = "$a.$b.$c"; } next unless defined $ip; push @{ $ips{$classc} }, $ip; } foreach $classc (sort keys %ips) { print $ips{$classc}[rand @{$ips{$classc}}] . "\n"; }
In reply to Re^4: Help with sorting/randomizing?
by countingcrows
in thread Help with sorting/randomizing?
by countingcrows
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |