#!/usr/bin/perl -w use strict; use IPC::Open2; $|=1; open2( my $read, my $write, "top -b" ); while( <$read> ) { print if /CPU states/ ; }