From: | Marc Horowitz <marc [...] mit.edu> |
To: | bug-X11-Protocol [...] rt.cpan.org |
Subject: | $x->ReqName(...) will fail if the request returns a scalar |
Date: | 12 Mar 2004 00:11:10 -0500 |
The following code does not work properly the first time:
my $atom = $x->InternAtom("STRING", 1);
The definition of X11::Protocol's AUTOLOAD uses a code path which ends
with
return @ret;
the first time any particular request is called. But with the
execution pattern above, the function is called in a scalar context,
which means @ret is interpreted in a scalar context, which means the
method will always return 1 the first time. This is true the first
time any protocol request which returns a scalar is called this way.
I believe the correct fix is to replace
return @ret;
with
return wantarray ? @ret : $ret[0];
Marc