Skip to content

Commit e14abd1

Browse files
haargbingos
authored andcommitted
lazy load Time::HiRes in ExtUtils::Command::MM (#263)
* lazy load Time::HiRes in ExtUtils::Command::MM * guard $@ in mtime lazy load
1 parent 4b20ee6 commit e14abd1

File tree

1 file changed

+9
-4
lines changed
  • lib/ExtUtils/Command

1 file changed

+9
-4
lines changed

lib/ExtUtils/Command/MM.pm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ $VERSION = eval $VERSION;
1515

1616
my $Is_VMS = $^O eq 'VMS';
1717

18-
eval { require Time::HiRes; die unless Time::HiRes->can("stat"); };
19-
*mtime = $@ ?
20-
sub { [ stat($_[0])]->[9] } :
21-
sub { [Time::HiRes::stat($_[0])]->[9] } ;
18+
sub mtime {
19+
no warnings 'redefine';
20+
local $@;
21+
*mtime = (eval { require Time::HiRes } && defined &Time::HiRes::stat)
22+
? sub { (Time::HiRes::stat($_[0]))[9] }
23+
: sub { ( stat($_[0]))[9] }
24+
;
25+
goto &mtime;
26+
}
2227

2328
=head1 NAME
2429

0 commit comments

Comments
 (0)