Re: XML::Simple Problem



Kodiak wrote:

Hi Tom,

I am somewhat of a newbie at perl so I do nto know how to check if the
hash reference is already parsed. I would like to know how do you
convert the hash reference into useable perl variables you can
manipulate. Thanks!


The output of

print Dumper ($dataResult);

should tell you what you're working with.

The short answer is that you can't usefully unload the hash until you know what keys are in it. You can dump it (that's what the Dumper was about), see what's there, and then figure out what to do with it.

For unloading the hash reference, see

$ perldoc perlreftut

(that's "Perl reference tutorial"). See also

$ perldoc perlref

Basically if you want key foo, do

$dataResult->{'foo'}

If foo turns out to be a list reference and you want element 2 of the list,

$dataResult->{'foo'}[2]

If foo turns out to be a hash reference and you want element bar,

$dataResult->{'foo'}{'bar'}

Tom Wyant
.



Relevant Pages

  • Problem using Perl web service with C# client.
    ... I have a perl web service with a method called ... "Detail" that returns a strucure (hash reference to be exact). ... works fine when consumed by a Perl client, but when I try to consume ... public class TestDetailService: ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: accessor problem in OO
    ... yes, if $ref_hash is a hash reference, you get the value associated to the ... is part of an array is no more relevant. ... Does this what Perl really sees: ... You call the namemethod of your object $obj (I call ...
    (perl.beginners)
  • Cant build SNMP...
    ... I get the following when trying to install the SNMP-4.2.0 into perl ... MAN3PODS takes a hash reference not a string/number. ... Can't use string as a HASH ref while "strict refs" in use at ...
    (comp.lang.perl.misc)
  • Re: new to Ruby - pls help in translating this
    ... > coming from a Perl background. ... You're assigning it to a %hash variable, ... Which creates a hash named %hash, stringifies the hash reference ...
    (comp.lang.ruby)
  • Re: XML::Simple Problem
    ... I am somewhat of a newbie at perl so I do nto know how to check if the ... convert the hash reference into useable perl variables you can ...
    (comp.lang.perl.modules)