Archive of UserLand's first discussion group, started October 5, 1998.
Re: How to push Perl hash through XML RPC?
Author: Kragen Sitaker Posted: 1/19/1999; 11:53:22 AM Topic: Frontier on MacOS X Server Msg #: 2261 (In response to 2227) Prev/Next: 2260 / 2262
OK, here's what's happening.You create a hash. Then you evaluate it in a list context, turning it into the list @args, containing 'state1', '18', 'state2', '27', 'state3', and '4', in that order. Then you pass this list to the call() method. Of course, call() has no way of knowing that that list came out of a hash originally, so it transmits it as a list.
In your second example, you say you initialize the hash with a {} list. I don't see how this is possible. Are you sure you typed it in correctly?
When I run the following program under perl 5.004_04
my %hash = {'a' => 'b'};
print '(', keys (%hash), ")\n";
the output I get is
()
This suggests to me that when you initialize a hash with an unbalanced list (that is, one containing an odd number of elements), the last one gets dropped. (And, of course, running under perl -w, I get the error message:
Odd number of elements in hash list at - line 1.
)
I haven't tried using the Frontier::Client module in Perl myself (is it on CPAN?), but I suspect you might get better results like this:
my $hash = {'state1' => 18, 'state2' => 27, 'state3' => 4};
# . . .
my $result = $server->call($method, $hash);
That way, Frontier::Client will at least be able to tell you're trying to send a struct. Whether it will *handle* it correctly, I don't know -- and I also don't know whether there's another way to get it to handle it.
That HASH(address) nonsense is what happens when you take a scalar that's a reference to a hash and interpret it in a string context, and it suggests to me that Frontier::Client might not gracefully handle being passed references to hashes. Why don't you grep the source code for "
"? On other topics:
Maybe the Frontier::Client module should be renamed something else -- XMLRPC::Client, perhaps. Not that I dislike Frontier, but I hope that XML-RPC will be bigger than Frontier is.
And when will Dave switch to using Basic HTTP authentication instead of this bloody cookie stuff? I hate having to enable cookies for just one or two web sites. I don't mind logging in, but having to enable cookies to log in is too much of a pain -- because then I forget and leave cookies enabled for other web sites, which I don't want.
There are responses to this message:
- Re: How to push Perl hash through XML RPC?, Ken MacLeod, 1/19/1999; 12:06:44 PM
This page was archived on 6/13/2001; 4:47:23 PM.
© Copyright 1998-2001 UserLand Software, Inc.