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

Ric*_*rth 6 installation module raku

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

if is-installed('GTK::Simple') { gui-response } else { cli-response };
Run Code Online (Sandbox Code Playgroud)

'is-installed'的主体应该是什么?

mor*_*itz 4

这是一种选择:

sub is-installed(Str $module-name) {
    try {
        require ::($module-name);
        return True;
    }
    False;
}
Run Code Online (Sandbox Code Playgroud)

查看文档以require获取更多背景信息。