i have written the following PHP function that masks a string with ***'s and then unveils 1/3 of its original letters to form a hint:
$length = strlen($answer);
$hint = "";
for ($x=0;$x<$length;$x++){
$hint .= "*";
}
for ($x=0;$x<($length/3);$x++){
$ran = rand(0,$length-1);
$hint[$ran] = $answer[$ran];
Now I need this in perl. I tried this:
$length = length($answer);
$lower=0;
$upper=$length;
$hint = "";
for ($x=0;$x<$length;$x++){
$hint .= "*";
}
for ($x=0;$x<($lengte/3);$x++){
$ran = int(rand( $upper-$lower+1 ) ) + $lower;
substr($hint, $ran, $ran) = substr($antwoord, $ran, $ran);
the masking to **** works but the unveiling doesnt work properly. Now I know nothing about perl so most probably theres an easy and correct way, could someone show me?
thanks
$length = strlen($answer);
$hint = "";
for ($x=0;$x<$length;$x++){
$hint .= "*";
}
for ($x=0;$x<($length/3);$x++){
$ran = rand(0,$length-1);
$hint[$ran] = $answer[$ran];
Now I need this in perl. I tried this:
$length = length($answer);
$lower=0;
$upper=$length;
$hint = "";
for ($x=0;$x<$length;$x++){
$hint .= "*";
}
for ($x=0;$x<($lengte/3);$x++){
$ran = int(rand( $upper-$lower+1 ) ) + $lower;
substr($hint, $ran, $ran) = substr($antwoord, $ran, $ran);
the masking to **** works but the unveiling doesnt work properly. Now I know nothing about perl so most probably theres an easy and correct way, could someone show me?
thanks