Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
XP is just a number
 
PerlMonks  

Frontier::RPC and Digest::MD5

by v_thunder (Scribe)
on Aug 29, 2003 at 19:31 UTC ( #287808=perlquestion: print w/ replies, xml ) Need Help??
v_thunder has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone,

I have a rather puzzling problem. I have invested quite some time in developing a set of applications that speak via xml-rpc using Frontier::Client and Frontier::Daemon. Everything seems to work fine, except I can't run strings through Digest::MD5 after they have gone through xml-rpc. I get the following error:

Use of uninitialized value in subroutine entry at ...

Digest::MD5::md5_hex does execute, but it returns the same hash that it would return if I were to pass it an empty string. I can print the string, however, no problem.

I've tried copying the string to another variable, I've tried using sprintf to make sure I get a new string back. Nothing seems to work. I am utterly confused! My next step will be to write it to a file and read it back, and failing that, to try to execute a separate process to do the md5sum. But, I figure someone here might have some insight as to what's going on.

Thanks!
-Dan

Comment on Frontier::RPC and Digest::MD5
Re: Frontier::RPC and Digest::MD5
by bear0053 (Hermit) on Aug 29, 2003 at 19:40 UTC
    can we see some code?

      Ok, I wrote some simple code to show this, and managed to narrow the problem down a little. Here is the code:

      This is the server:

      #!/usr/bin/perl -w use strict; use Frontier::Daemon; use Digest::MD5 qw/md5_hex/; Frontier::Daemon->new (LocalPort => 12345, methods =>{md5=>sub {return md5_hex (shift)}}); __END__

      And the client:

      #!/usr/bin/perl -w use strict; use Frontier::Client; my $rpc = Frontier::Client->new (url =>"http://localhost:12345/RPC2"); print $rpc->call ("md5", "1234"), $/; __END__

      For reference:

      md5 of "1234": 81dc9bdb52d04dc20036dbd8313ed055
      md5 of "": d41d8cd98f00b204e9800998ecf8427e

      Now, here's what I found. If I run the server on my desktop (perl 5.8.0), I get the expected result (81dc..). If I run the server on an older system (perl 5.6.1), I get the erroneous one (d41d..), along with the error on the console:

      Use of uninitialized value in subroutine entry at ./srv line 8.

      I have also found that even in the older system, the following code works:

      sub my_md5_hex { my ($str) = @_; my $cmd = "perl -MDigest::MD5 -e " . "'print Digest::MD5::md5_hex (\"$str\"), \$/'"; my $md5 = `$cmd`; chomp ($md5); return $md5; }

      It's pretty gross, though.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://287808]
Approved by krisahoch
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-04-20 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls