Raku - 程序如何验证模块是否安装在本地

Raku - How can a program verify if a module is installed locally

如何查看本地是否安装了Raku模块?如果未安装某些模块,例如。 GUI,然后将使用 CLI。例如

if is-installed('GTK::Simple') { gui-response } else { cli-response };

'is-installed' 的正文应该是什么?

这是一种选择:

sub is-installed(Str $module-name) {
    try {
        require ::($module-name);
        return True;
    }
    False;
}

查看 documentation for require 了解更多背景信息。