| ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
| uneval | Fonction réciproque de la fonction "eval"
Par exemple : eval(uneval(x)) retourne la valeur de x.
La fonction n'échappe pas les caractères d'interpolation Perl : $, @, %, & n'insère pas \ (back-slash).
| |||||||||
| Syntaxe | uneval(x) | |||||||||
| Paramètres |
| |||||||||
| Fonctions util. | Néant |
| Code Perl |
sub uneval {local($x) = @_;
if ($x eq "") {return "\"\""};
$x =~ s/\\/\\\\/gi; $x =~ s/\n/\\n/gi; $x =~ s/\"/\\\"/gi; $x =~ s/\'/\\\'/gi;
return "\"".$x."\"";
}
|
| Code JavaScript |
function uneval(x) {
if (x=="") {return "\"\""};
x = x.replace(/\\/gi,"\\\\"); x = x.replace(/\n/gi,"\\n"); x = x.replace(/\"/gi,"\\\""); x = x.replace(/\'/gi,"\\\'");
return "\""+x+"\"";
}
|