while (1) { my $top_output = `top -l 1`; do_something_with( $top_output ); sleep 5; }