Advertisement
Guest User

Untitled

a guest
Aug 10th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.64 KB | None | 0 0
  1. my sub load-modules($base, $namespace, $name-matcher) {
  2.   say "load-modules";
  3.   list-modules($base, $namespace, $name-matcher)
  4.     .map({ require-module( $_ ) })
  5.     .grep({ !.isa(Nil) })                   # Filter out modules that failed to load
  6.     .unique                                 # Potentially, there could be the same module installed and in lib at the same time
  7.     .Array;
  8. }
  9.  
  10. my sub require-module($module-name) {
  11.   try {
  12.     require ::($module-name);
  13.     return ::($module-name);
  14.   }
  15.  
  16.   given $! {
  17.     .say if ($*DEBUG-PLUGINS//False);
  18.     say .WHAT.perl, do given .backtrace[0] { .file, .line, .subname }
  19.     return;
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement