#!/usr/bin/perl use warnings; use strict; my $pid = $$; #my $pid0 = open(FH, "long strange work" |) or die "$\n"; my $pid1 = open(TH,"top -d 0 -b -p $pid |"); while(1){ my @words = split(/\s+/,); $words[0] ||= 0; if($words[0] eq $pid){ print "$words[4] $words[9] \n"} }