in reply to XML::Simple finding id property problem

That can't "works pretty good" - it's not Perl (// is not a Perl comment).

Unless you understand what they actually do and you have a real reason to use them, do not use prototypes (see perlsub). Prototypes generally do not do what you expect if you come from another language such as C++!

If I run:

use XML::Simple; use strict; use warnings; my $xml = <<XML; <root> <outputText styleClass="required" value="*" id="AdjustCCDetails_Reason +Code_table_required_id" /> </root> XML my $config = XMLin ($xml); processhash ($config, '$config'); sub processhash { my ($href, $path, @junk) = @_; my %configr = %$href; foreach my $k (keys %configr) { print qq|$path :: $k = $configr{$k}\n|; if ($configr{$k} =~ m/HASH/i) { processhash ($configr{$k}, qq|$path -> {'$k'}|); } } }

it prints:

$config :: outputText = HASH(0x2106718) $config -> {'outputText'} :: value = * $config -> {'outputText'} :: id = AdjustCCDetails_ReasonCode_table_req +uired_id $config -> {'outputText'} :: styleClass = required

which is what you expected (so far as I can tell). What have you done differently? Can you modify my sample to illustrate your problem?


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^2: XML::Simple finding id property problem
by JohnEl (Initiate) on May 28, 2008 at 21:12 UTC
    "That can't "works pretty good" - it's not Perl (// is not a Perl comment)."
    The // was a slip of the finger in my editor, I was trying to keep my post uncomplicated, and make it obvious what I was doing in that line.
    It wasn't really a prototype, it was just a mistake made from going too fast; the network here was scheduled to go down and I was in a rush.
    I didn't use the code tags because I was in a rush and forgot about them, yes, even though the warning against them is on the page.
    I apologize for taking up your time, and to anyone else who was put out by my post