s/^(\S+[ ]+\S+[ ]+\S+[ ]+\S+[ ]+)(\S+[ ]+)/ my $s = int(rand($2)); $1 . $s . (' ' x (length($2) - length($s))) /e;