|Pathologically Eclectic Rubbish Lister|
Iterating through process hierarchyby ovedpo15 (Monk)
|on Jan 06, 2019 at 15:25 UTC||Need Help??|
ovedpo15 has asked for the wisdom of the Perl Monks concerning the following question:
I sorry that it will be a long thread and with a lot of data.
Also, I hope I'll make my point (English is my third language).
Before trying to explain my issue, I'll try to explain what I did.
On my previous thread (link:https://www.perlmonks.org/?node_id=1227383) I asked to convert:
to a file with the following format: id,parent-id,name.
With your help (BTW thanks again guys!), I created the following function:
It works great! it clear and readable (at least for me), and it does not use any additional modules.
Now I would like to explain my issue.
I have created the following two hashes:
Second hash: (as the one was described in the opening, but I didn't include the other data like start and end, so it will be readable)
I'll try to explain a bit about those hashes. The first hash has files as keys.
Each key contains two fields as values - pid and data.
I don't really care about the data, but I do care about the pid.
The pid hash contains all the pids that touched the current path (the key of the main first hash) during the run.
Each pid points to the duration time (also, not important data for now).
The second hash, contains pids as keys and each pid hash two values: parent-pid and and a name.
From the second hash, I can understand that:
I would like to create a file which contains: for each one of the files in the first hash, I would like to create a the chain to get to the '###' main parent.
For example if file A has process 3, file B has process 5 and file C hash process 7 and also we have the following chain: `###->3->5->7` we will get:
I just iterated through the files and checked each parent id.
The second hash has the hierarchy which the first hash should follow.
My main goal is to create a function which creates the file with the data.
The reason I included all the information and the code in the beginning of the thread
is because the issue is similar and I would like to create an efficient function which creates those files (the one from previous thread and the new one).
1. I'm trying to create a function which gets two hashes and creates a file which has the following format:
2. Combine the function with already existing function.
The reason I like that solution in the previous thread is because its clear, readable and does not include any additional modules.
If you need some additional explanation, I would be more than happy to do so.
Thank you all for the help! Iterating through process hierarchy