use strict; use warnings; use File::Spec::Functions qw(catfile); my @loaded = grep { eval "require $_"; !$@ ? 1 : ($@ =~ s/\(\@INC contains: \Q@INC\E\)//, warn("Failed loading $_: $@"), 0); } @ARGV; my @pm = map catfile(split '::') . (/\.pm\z/ ? '' : '.pm'), @loaded; print "@INC{@pm}\n";