use IPC::Run; my $clopts = '-p 5432 -e --dbname=postgres -U postgres'; my $stdout; my $stderr; my @cmd = ('clusterdb', split /\s+/, $clopts); my $ch; for (my $i =0; $i < 2*4096; $i++) { $ch = IPC::Run::run(\@cmd, '>', \$stdout, '2>', \$stderr); if(not defined $stdout) { print($i.": not defined\n"); } if($stdout eq '') { print($i.": stdout is empty\n"); } if ( ($i % 100) == 0){ print("$i\n"); } }