@@ -278,13 +278,13 @@ sub get_deps {
278278 foreach my $n ( $deps->required_modules ) {
279279 next if $n eq "perl";
280280
281− # Hacky way to figure out if this module is part of Perl.
282− if ( $n !~ /^JSON/ && $n !~ /^YAML/ && $n !~ /^Module::Pluggable/ && $n !~ /^if$/ ) {
283− eval "use $n;";
284− if ( !$@ ) {
285− DEBUG("skipping Perl-builtin module $n");
286− next;
287− }
281+ # Figure out whether the module is a core module by attempting
282+ # to `use` the module in a pure Perl interpreter and checking
283+ # whether it succeeded. Note, $^X is a magic variable holding
284+ # the path to the running Perl interpreter.
285+ if ( system("env -i $^X -M$n -e1 >/dev/null 2>&1") == 0 ) {
286+ DEBUG("skipping Perl-builtin module $n");
287+ next;
288288 }
289289
290290 my $pkg = module_to_pkg( $cb, $n );