我在 Perl 中使用了 CPAN Perl 模块 Data::Printer (DP)。它工作得很好。
现在我想在 Raku 代码中使用它。
当我使用该:from<Perl5>功能导入它然后使用它运行代码时,注释(tied to Perl6::Hash)会附加到哈希的显示中。1
正如DP 的 CPAN 文档所示,此注释由选项控制show_tied。我想将其关闭(设置为0)而不是默认开启(设置为1)。这是我在 Perl 中的做法:
use Data::Printer show_tied => 0;
Run Code Online (Sandbox Code Playgroud)
但是当我在 Raku 中尝试这个时:
use Data::Printer:from<Perl5> show_tied => 0;
Run Code Online (Sandbox Code Playgroud)
我得到:
从“Data::Printer”导入时出错:没有这样的标签“show_tied”
show_tied在 Raku 中使用 DP 时如何关闭?
1也许这是因为Inline::Perl5(实现该:from<Perl5>功能)正在做一些事情来实现流畅的 Perl/Raku 互操作。
我一直在尝试将Perl5模块加载Data::Printer到Perl6中,但是我很难过.
我之前问过这个问题,不能使用Inline :: Perl5将Perl5模块导入Perl6并从@raiph和Elizabeth那里得到有用的建议,但建议再做一个问题
con@con-VirtualBox:~$ perldoc -lm Data::Printer
/usr/local/share/perl/5.26.0/Data/Printer.pm
con@con-VirtualBox:~$ perl6
To exit type 'exit' or '^D'
> use Inline::Perl5;
Nil
> use lib:from<Perl5> '/usr/local/share/perl/5.26.0/Data/';
Nil
> my @a = 1,2,3,4
[1 2 3 4]
> p @a
===SORRY!=== Error while compiling:
Undeclared routine:
p used at line 1
Run Code Online (Sandbox Code Playgroud)
该p程序应该被加载,然而事实并非如此.
或者,我尝试加载,但这也会产生错误
> use Data::Printer:from<Perl5>
Unsupported type NativeCall::Types::Pointer<94859011731840> in p5_to_p6
in method p5_to_p6_type at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 298
in method unpack_return_values at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line …Run Code Online (Sandbox Code Playgroud) 我正在Perl6中打印数据,Data::Printer这是一个很棒的程序包,但是我试图更改参数,但我不能。
例如,我想要:
HG00112 {
gained_site {
9:10162 0,
9:10272 var{HG00112}{gained_site}{9:10162},
9:10326 var{HG00112}{gained_site}{9:10162},
...
}(tied to Perl6::Hash)
Run Code Online (Sandbox Code Playgroud)
看起来像
HG00112 {
gained_site {
9:10162 0,
9:10272 0,
9:10326 0,
...
}(tied to Perl6::Hash)
Run Code Online (Sandbox Code Playgroud)
易于阅读(我不在乎tied to Perl6::Hash)
可以使用JSON看到此哈希元素:
"HG00112": {
"discordant_multiallelic_loss": 0,
"concordant_hom_alt": 4,
"discordant_het_to_alt": 0,
"discordant_hom_alt_to_ref": 0,
"discordant_hom_ref_to_alt": 0,
"lost_site": 0,
"concordant_het": 3,
"discordant_multiallelic_gain": 0,
"discordant_hom_alt_to_het": 0,
"discordant_call_to_no_call": 0,
"discordant_het_to_ref": 0,
"concordant_hom_ref": 5,
"concordant_site": 18,
"discordant_no_call_to_call": 0,
"concordant_no_call": 6,
"concordant_multiallelic": 0,
"gained_site": 0,
"discordant_hom_ref_to_het": 0
}
Run Code Online (Sandbox Code Playgroud)
我通常使用加载软件包use …