Skip to content

Instantly share code, notes, and snippets.

@worthmine
Last active September 25, 2020 10:29
Show Gist options
  • Save worthmine/14f04b825dc11cb5da811f47d83965fb to your computer and use it in GitHub Desktop.
Save worthmine/14f04b825dc11cb5da811f47d83965fb to your computer and use it in GitHub Desktop.
trying to detect for NOT (CORE|EXSISTING) module names in Perl
use 5.008_009; # because Module::CoreList was first released with perl v5.8.9
#use strict; # this line is irrelevant
#use warnings; # this line is irrelevant
use feature qw(say);
#use FastGlob qw(glob); # this line is irrelevant
my @modules = qw(Encode FastGlob CGI Dummy);
#local @INC = qw(lib); # this line is irrelevant
my @list;
for (@modules) {
eval { require $_ } or $@ =~ /^Can't locate ([A-Za-z][^\s]+)/;
say "for $1" if my $name = $1;
say my $res = qx"corelist $name";
push @list, $name if $res =~ /$name was not in CORE/;
}
say 'results:';
say "- $_" for @list;
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment