Subject: | use Time::HiRes and Time::Out order |
In the sample code lines in Time::Out's Pod for using Time::HiRes together with Time::Out, the order of the use statements is wrong. "use Time::HiRes" has to happen before "use Time::Out", otherwise only int timeouts are used.
Try the following sample code (suitable as a test script). If "use Time::HiRes" comes before "use Time::Out", then the test script passes.
#!/usr/bin/perl
use strict;
use warnings;
use Time::Out qw(timeout);
use Time::HiRes;
use Test::More 'no_plan';
timeout 0.1 => sub {
sleep 1;
};
if ($@) {
pass "Timeout happened";
} else {
fail "No timeout";
}
__END__