How would I discover whether a Raku module has been installed locally? If some module is not installed, eg. a GUI, then a CLI would be used. Eg.
if is-installed('GTK::Simple') { gui-response } else { cli-response };
What should be the body of 'is-installed'?
Here's one option:
sub is-installed(Str $module-name) {
try {
require ::($module-name);
return True;
}
False;
}
Check the documentation for require
for more background information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With