#!/usr/bin/perl 

use strict;

my $proc0=$ARGV[0];
my $proc1=$ARGV[1];
my ( @out, @vars );
my ( $pid, $counter );
my %pids;

while (1) {
	@out=qx "top -b -n 1 -p $proc0,$proc1";

	$out[7] =~ s/^ +//;
	@vars=split(/ +/,$out[7]);
	$vars[8]=~s/\..*//;
	$pids{$vars[0]}=$vars[8];
	
	$out[8] =~ s/^ +//;
	@vars=split(/ +/,$out[8]);
	$vars[8]=~s/\..*//;
	$pids{$vars[0]}=$vars[8];

	$counter=0;
	for my $key ( keys %pids ) {
        	print $counter++,":$pids{$key}\n";
    	};

	system "sleep 0.7";
	# sleep 1;
}
