sub mutate() { my $self = shift; # my $strength = shift || 2; my($i, $p1, $p2, $c1, $c2); my $my_astr = $self->astr(); # Get $strength (2) positions and flip the characters $c1 = substr($my_astr, $p1 = int rand(length($my_astr)), 1); $c2 = substr($my_astr, $p2 = int rand(length($my_astr)), 1); substr($my_astr, $p1, 1, $c2); substr($my_astr, $p2, 1, $c1); return $self->astr($my_astr); }