| ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
| fromJsPl | Traduire de Perl à JavaScript (dans les cas simples) | |||||||||
| Syntaxe | fromPlJs(x) | |||||||||
| Paramètres |
| |||||||||
| Fonctions util. |
|
| Code Perl |
sub fromPlJs {local($x) = @_;
if ($client eq "true") {
$x = "\n".$x;
$x =~ s/\n(\w+) = \(/\n$1 = \(/gi;
$x =~ s/\n\$(\w+) = /\n$1 = /gi;
$x =~ s/\n\@\{\$(\w+)\[(\w+)\]\} = \(/\n$1\($2\) = \(/gi;
$x =~ s/\n\$(\w+)\[(\w+)\] = /\n$1\($2\) = /gi;
$x =~ s/\n#/\n\/\//gi;
$x =~ s/\(/\[/gi; $x =~ s/\)/\]/gi;
$x = substr($x,1)
}
return $x;
}
|
| Code JavaScript |
function fromPlJs(x) {
if (client=="true") {
x = "\n"+x;
x = x.replace(/\n(\w+) = \(/gi,"\n$1 = \(");
x = x.replace(/\n\$(\w+) = /gi,"\n$1 = ");
x = x.replace(/\n\@\{\$(\w+)\[(\w+)\]\} = \(/gi,"\n$1\($2\) = \(");
x = x.replace(/\n\$(\w+)\[(\w+)\] = /gi,"\n$1\($2\) = ");
x = x.replace(/\n#/gi,"\n\/\/");
x = x.replace(/\(/gi,"\["); x = x.replace(/\)/gi,"\]");
x = x.substr(1)
}
return x;
}
|