Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by AnomalousMonk (Bishop)
on Apr 19, 2021 at 09:15 UTC ( #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 (Initiate) 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
Node Status?
node history
Node Type: note [id://11131462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2021-05-10 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (103 votes). Check out past polls.

    Notices?