Home Index
1 Programming
2 Challenge
+ Hoppity
|
|
#!/usr/bin/perl
use strict;
use warnings;
#--------------------------------------------------------#
# Vindicia programming challenge
# Written by Kevin Duraj
#--------------------------------------------------------#
my $hash_ref = {};
my @file = `ps -e l`;
foreach my $line (@file)
{
chomp $line;
my @array = split(/\s+/, $line);
my $pid = $array[3];
my $ppid = $array[4];
my $name = $array[12];
$hash_ref->{$pid}->{$ppid} = $name;
}
&print_hashes($hash_ref);
#--------------------------------------------------------#
sub print_hashes
{
my $hash_ref = shift;
for my $key1 (keys %$hash_ref)
{
print "\n$key1\n";
for my $key2 (keys %{$hash_ref->{$key1}})
{
print " \\_ $hash_ref->{$key1}->{$key2}\n";
}
}
}
#--------------------------------------------------------#
__END__
|
|
Copyright © 1997-2012 Kevin T. Duraj, All rights reserved
Agoura Hills, California -
Saturday, 19 May 2012
|
|
|