我正在尝试用Perl中的随机数替换IP地址:
while (my $line = <file>){ $line =~ $regex{'ipadress'}; my $rand0 = int(rand(256)); my $rand1 = int(rand(256)); my $rand2 = int(rand(256)); my $rand3 = int(rand(256)); $& = "$rand0.$rand1.$rand2.$rand3\n";` }
问题是在某些情况下,一行中有多个IP地址.
如何避免它们都得到相同的随机数?