sub monitor_cpu { my $cap; while ( my $val = $q->peek(0) ) { #this does not get evaluated to true, ever $cap .= `bash cpu.sh; sleep 2`; } return $cap; }