Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Iterating through process hierarchy

by tybalt89 (Parson)
on Jan 06, 2019 at 19:09 UTC ( #1228113=note: print w/replies, xml ) Need Help??


in reply to Iterating through process hierarchy

#!/usr/bin/perl # https://perlmonks.org/?node_id=1228107 use strict; use warnings; my $firsthash = { "./bye_world.pl" => { data => 4, pid => { 7302 => 2 } }, "./hello_world.pl" => { data => 4, pid => { 7287 => 2 } }, "/perl/5.14.1/strict.pm" => { data => 6, pid => { 7287 => 1, 7302 => + 1 } }, "/some_text.txt/" => { data => 2, pid => { 7287 => 1, 7302 => + 1 } }, }; my $secondhash = { 7287 => { name => "./hello_world.pl", parent => "###" }, 7299 => { name => "echo Hello World ", parent => 7287 }, 7302 => { name => "./bye_world.pl", parent => 7287 }, 7305 => { name => "echo Bye World ", parent => 7302 }, }; sub parents { my ($name, $pid) = @_; exists $secondhash->{$pid} or return ''; my $secondname = $secondhash->{$pid}{name}; return ($name ne $secondname and ",$secondname") . parents($secondname, $secondhash->{$pid}{parent}); } for my $name ( keys %$firsthash ) { for my $pid ( keys %{ $firsthash->{$name}{pid} } ) { print $name, parents($name, $pid), "\n"; } }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-05-31 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (175 votes). Check out past polls.

    Notices?