[gull] question Perl (basique)
Félix Hauri
felix at f-hauri.ch
Wed Oct 12 10:51:51 CEST 2011
Salut Marc,
On Wed, Oct 12, 2011 at 01:55:36AM +0200, Marc Mongenet wrote:
> Bonjour,
>
> http://search.cpan.org/~rjray/RPC-XML-0.76/lib/RPC/XML.pm
> ...
> $ENCODING
>
> This variable controls the character-set encoding...
>
>
> Comment est-ce qu'on importe (et utilise) une variable ($ENCODING en
> l'occurrence) ?
Si j'ai bien compris, la variable n'est pas utilisée, mais juste
reconduite:
$ find /usr/share/perl5/RPC -type f -print0 | xargs -0 grep -H ENCODING
Cette commande éclaire déjà la réponse pour son ``utilisation''.
Pour ce qui est de l'importer, c'est une variable glogale:
use RPC::XML...
$RPC::XML::ENCODING="Chose";
Petit test dans une console shell:
$ perl -MRPC::XML -e '
$RPC::XML::ENCODING="zorglub";
my $req = RPC::XML::request->new("NomDeChose","Serie de trucs");
printf "%s\n",$req->as_string;
'
<?xml version="1.0" encoding="zorglub"?><methodCall><methodName>NomDeChose</methodName><params><param><value><string>Serie
de trucs</string></value></param></params></methodCall>
ou encore:
$ perl -e '
use RPC::XML qw|$ENCODING|;
$ENCODING="zorglub";
my $req = RPC::XML::request->new("NomDeChose","Serie de trucs");
printf "%s\n",$req->as_string;
'
<?xml version="1.0" encoding="zorglub"?><methodCall><methodName>NomDeChose</methodName><params><param><value><string>Serie
de trucs</string></value></param></params></methodCall>
--
Félix Hauri - <felix at f-hauri.ch> - http://www.f-hauri.ch
More information about the gull
mailing list