$other = "x!4Y"; $password = $PATTERN; # $PATTERN is aHINTbcd $password =~ s/a/x/; # or $password =~ s/a/substr($other,0,1)/e; $password =~ s/b/!/; $password =~ s/c/4/; $password =~ s/d/Y/; #### $other = "x!4Y"; $password = $PATTERN; # $PATTERN is aHINTbcd $password =~ tr/abcd/$other/; #### $password = substr($other, 0, 1).$HINT.substr($other, 1, 3); #### $password = join('', substr($other, 0, 1), $HINT, substr($other, 1, 3));