Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How do I get a list in a perl hash generated from an XML?

by AnomalousMonk (Archbishop)
on Apr 19, 2021 at 09:15 UTC ( [id://11131462]=note: print w/replies, xml ) Need Help??


in reply to How do I get a list in a perl hash generated from an XML?

If you're determined to disregard the sound advice against the use of XML::Simple, you can do

Win8 Strawberry 5.8.9.5 (32) Mon 04/19/2021 5:08:21 C:\@Work\Perl\monks >perl -Mstrict -Mwarnings use Data::Dumper; my $got_data = { 'ref' => { 'abc_sia_%version1.ref' => { 'func' => [ { 'envname' => 'test01', 'objectdir' => '/home/pv66', 'base' => 'default_771' } ] } } }; my $want_data = $got_data->{'ref'}; print Dumper $want_data; ^Z $VAR1 = { 'abc_sia_%version1.ref' => { 'func' => [ { 'base' => 'defaul +t_771', 'objectdir' => '/ +home/pv66', 'envname' => 'tes +t01' } ] } };
It looks like the hash reference you want is just the value of the 'ref' key. See also perldsc.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: How do I get a list in a perl hash generated from an XML?
by PV66 (Novice) on Apr 19, 2021 at 09:46 UTC
    Thanks a lot!!!! This did resolve the issue for which I've been scratching my head for so long and it did turn out to be a very efficient, and yeah I'm okay with using XML::Simple in this case :P

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11131462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-23 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found