Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Traversing a complex data structure searching for certain keys and printing their values

by newperluser2013 (Novice)
on Apr 29, 2013 at 02:22 UTC ( #1031144=note: print w/replies, xml ) Need Help??


in reply to Re^3: Traversing a complex data structure searching for certain keys and printing their values
in thread Traversing a complex data structure searching for certain keys and printing their values

Thanks ever so much for your help choroba I have made the changes you suggested and this is now working perfectly :-) Just one thing if you can help. In the sample data structure I posted there is a @dev tag in this and I need to get this value prepended to each line of output. I mustn't hardcode this though. I have other hashes of hashes defined under this whole @dev section which are called @build and @software (which both have loads of mount definitions in )and to each of the lines printed when I parse these I need to prepend the corresponding tag @build/@software. Would you be able to help me with what I need to do here please?

  • Comment on Re^4: Traversing a complex data structure searching for certain keys and printing their values

Replies are listed 'Best First'.
Re^5: Traversing a complex data structure searching for certain keys and printing their values
by choroba (Chancellor) on Apr 29, 2013 at 12:19 UTC
    I hope the hints I have given should be enough for you to hack a solution yourself. If there are details you still do not grasp, feel free to ask a new question, but do not await we do your work for you.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^5: Traversing a complex data structure searching for certain keys and printing their values
by newperluser2013 (Novice) on Apr 29, 2013 at 02:43 UTC

    Just one other thing would you know what I would need to do to this sub routine so that I could get different output formats? For example I still need to pass in @keylist to the subroutine to make sure all the keys are there but I want to also parse in an output format string aswell. So for example if I wanted to print all the lines like this:

    %export_name:%filer_device:%filer_volume

    or print them with every value like this:

    %export_name:%filer_device:%filer_volume:%mount_acl:%mount_group:%moun +t_user:%mount_opts

    So I want to be able to pass in $output_format to this function. $output_format equates to one of the strings above. So I could the run funtion like this:

    recurse_hash(\%$decoded_json_obj, {}, @keylist, $output_format);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031144]
help
Chatterbox?
[hippo]: I had a low-paid job about 20 years ago and seriously considered going down to a 3-day week. Would have worked 60% of the time for about 80% of the cash.
[Corion]: ambrus: Well, I pay rent, but don't own a house with variable/ unforeseeable costs
[hippo]: The thesholds/benefits balance at the time was nuts.
[hippo]: But that doesn't last because, you know ... politicians. :(
[Corion]: hippo: Yeah, if you still get enough money to get by and don't have expensive hobbies or other fixed costs that can work out well
[ambrus]: ah good. I pay only rent too. but that still costs significant money.
[Corion]: ambrus: Yes, but that is already budgeted for

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-09-21 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (249 votes). Check out past polls.

    Notices?