use strict; open (OUT,">top.log") or die "cannot create: $!\n"; for (;;){ my $top = `top n 1`; print $top; sleep 10; } close OUT;