| ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
| fromJsPl | Traduire de JavaScript à Perl (dans les cas simples) | |||||||||
| Syntaxe | fromJsPl(x) | |||||||||
| Paramètres |
| |||||||||
| Fonctions util. |
|
| Code Perl |
sub fromJsPl {local($x) = @_;
if ($client ne "true") {
$x = "\n".$x;
$x =~ s/\[/\(/gi; $x =~ s/\]/\)/gi;
$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 = substr($x,1);
}
return $x;
}
|
| Code JavaScript |
function fromJsPl(x) {
if (client!="true") {
x = "\n"+x;
x = x.replace(/\[/gi,"\("); x = x.replace(/\]/gi,"\)");
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.substr(1);
}
return x;
}
|