I have a command line function I'd like to execute in Perl. However, I only want it to run for up to X seconds. If at X seconds, no result is returned, I want to move on. For instance, if I wanted to do something like
sub timedFunction {
my $result = `df -h`;
return $result;
}
How could I kill the wait for the command line command to finish if it's not returned any values after 3 seconds?