我正在尝试 使用手册页https://modules.perl6.org/dist/Inline::Perl5:cpan中的建议导入一个我非常喜欢https://metacpan.org/pod/Data::Printer的Perl5模块:九
使用一个非常简单的脚本
use Inline::Perl5;
my $p5 = Inline::Perl5.new;
$p5.use('Data::Printer');
Run Code Online (Sandbox Code Playgroud)
但后来我收到这个错误:
Unsupported type NativeCall::Types::Pointer<94774650480224> 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 375
in method invoke at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 446
in method import at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 776
in method use at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 898
in block <unit> at inline_perl5.p6 line 4
Run Code Online (Sandbox Code Playgroud)
这里出了什么问题?如何将perl5模块导入perl6?如果有类似的方法来获取Perl6中的彩色/标签输出,我会很高兴,Data::Printer
因为我找不到它.
编辑:这在这里解决:如何在Perl6中加载Perl5的Data :: Printer?
我一直在尝试从Perl5学习Perl6,但问题是正则表达式的工作方式不同,而且工作不正常.
我正在制作一个测试用例,列出以".p6 $"结尾的目录中的所有文件
此代码适用于结束字符
if 'read.p6' ~~ /read\.p6$/ {
say "'read.p6' contains 'p6'";
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试将其放入子例程中:
multi list_files_regex (Str $regex) {
my @files = dir;
for @files -> $file {
if $file.path ~~ /$regex/ {
say $file.path;
}
}
}
Run Code Online (Sandbox Code Playgroud)
它不再有效.我不认为正则表达式的问题,但与文件名,可能有一些我不知道的属性.
如何获取文件名以匹配Perl6中的正则表达式?
我正在尝试使用Perl6运行一系列shell命令到变量$cmd
,看起来像
databricks jobs run-now --job-id 35 --notebook-params '{"directory": "s3://bucket", "output": "s3://bucket/extension", "sampleID_to_canonical_id_map": "s3://somefile.csv"}'
notebook-params
我的$ cmd0 ='databricks jobs run-now --job-id 35 --notebook-params'; 我的$ args ="'{\"目录\":\"$ in-dir \",\"output \":\"$ out-dir \",\"sampleID_to_canonical_id_map \":\"$ map \"} ""; 我的$ run = run $ cmd0,$ args,:err,:out;
失败.Databricks或shell都没有回答.Stdout和stderr都是空的.
用空格分割整个命令
我的@cmd = $ cmd.split(/\s + /); 我的$ run = run $ cmd,:err,:out
错误:获得意外的额外参数("s3:// bucket","output":"s3:// bucket/extension","sampleID_to_canonical_id_map":"s3://somefile.csv"}'
再次,stdout和stderr是空的.退出代码1.
这是关于如何run
只接受数组,而不是字符串(我很奇怪为什么)
如果我复制并粘贴给Perl6的命令 …
我正在从Perl5学习Perl6.
我正在查看副词:exists
https://docs.perl6.org/type/Hash#:exists但是没有:defined
副词
但我很担心,因为perl5 exists
与&之间有区别defined
:存在和定义之间有什么区别?
我怎样才能在Perl6中做这样的事情?
if (defined $hash{key}) {
$hash{key}++;
} else {
$hash{key} = 1;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在perl6中为zef安装Linenoise.
user@centos:/illumina/runs/Scripts/perl6/zef$ sudo bin/zef install Linenoise --force-build
===> Searching for: Linenoise
===> Searching for missing dependencies: LibraryMake
===> Searching for missing dependencies: Shell::Command
===> Searching for missing dependencies: File::Which, File::Find
===> Building: Linenoise:ver<0.1.1>:auth<Rob Hoelz>
/bin/ld: cannot find -luv
collect2: error: ld returned 1 exit status
make: *** [/root/.zef/store/p6-linenoise.git/480fd919b2c082e691c518fd50c19ad8719532b6/resources/libraries/liblinenoise.so] Error 1
Run Code Online (Sandbox Code Playgroud)
我不知道如何找到并安装这个库"-luv".我找不到有关互联网搜索引擎的信息.
我试着yum search
和yum search all
我不能找出如何安装它.
我试图在Perl6中按年龄获取目录列表,这等效于Bash,ls -tl | grep ^dr
但是我什至不确定如何按年龄对结果进行排序
for dir (test => {$_.IO.d}) -> $dir {...}
如何按目录年龄对这些结果进行排序?
我很高兴得知 Perl 可以在 5.32 版中处理链式比较
但是,我正在尝试进行链式正则表达式比较,以使我的代码更短更干净
#!/usr/bin/env perl
use 5.032;
use strict;
use warnings FATAL => 'all';
use feature 'say';
use autodie ':all';
if (9 > 2 < 3 < 4 > 0) {
say 'chained expressions work.'
} else {
say 'chained expressions do not work.'
}
my $x = 4;
my $z = 4;
if ($x == 4 == $z) {
say 'chained equality works';
}
$x = 'x';
$z = 'x';
if ($x eq 'x' eq $z) …
Run Code Online (Sandbox Code Playgroud) 我正在尝试DateTime
在我的 perlbrew 5.32.0上安装,但对其依赖项的测试Test::File
失败了。重要的部分如下:
t/owner.t ..................... # File [blib] belongs to 703404669 (729761796), not 703404669 (703404669)!
t/owner.t ..................... 1/?
# Failed test 'owner_is with text username'
# at t/owner.t line 99.
# Failed test 'Intentional owner_isnt failure'
# at t/owner.t line 146.
# STDOUT is:
# > ok 1 - blib doesn't belong to 703404669
# not:
# > not ok 1 - blib doesn't belong to 703404669
# as expected
# STDERR is:
# >
# …
Run Code Online (Sandbox Code Playgroud) 我正在尝试对字符串列表/数组进行排序:
> my @e = Q (list_regex_files json_file_to_ref write_2d_array_to_tex_tabular dir get_sample_ID density_scatterplot violin_plot multiline_plot ref_to_json_file execute venn barplot scatterplot_2d_color worksheet_to_hash group_bar workbook_to_hash read_table)
Run Code Online (Sandbox Code Playgroud)
使用https://docs.raku.org/type/Array#(List)_routine_sort我尝试
> say @e.sort
(list_regex_files json_file_to_ref write_2d_array_to_tex_tabular dir get_sample_ID density_scatterplot violin_plot multiline_plot ref_to_json_file execute venn barplot scatterplot_2d_color worksheet_to_hash group_bar workbook_to_hash read_table)
Run Code Online (Sandbox Code Playgroud)
但
say <list_regex_files json_file_to_ref write_2d_array_to_tex_tabular dir get_sample_ID density_scatterplot violin_plot multiline_plot ref_to_json_file execute venn barplot scatterplot_2d_color worksheet_to_hash group_bar workbook_to_hash read_table>.sort
Run Code Online (Sandbox Code Playgroud)
确实有效。但是,如何将数据保存到数组中然后对其进行排序?喜欢say @e.sort
?
我有以下代码:
#!/usr/bin/env perl
use 5.0360;
use warnings FATAL => 'all';
use autodie ':default';
use Devel::Confess 'color'; # not essential, but better error reporting
open my $view, "zcat a.big.file.vcf.gz|"; # zcat or bcftools
while (<$view>) {
next unless /^#CHROM\t/;
last;
}
close $view;
Run Code Online (Sandbox Code Playgroud)
上面的代码因错误而崩溃
Can't close(GLOB(0x55adfa96ebf8)) filehandle: '' at (eval 11)[/home/con/perl5/perlbrew/perls/perl-5.36.0/lib/5.36.0/Fatal.pm:1683] line 74
at (eval 11)[/home/con/perl5/perlbrew/perls/perl-5.36.0/lib/5.36.0/Fatal.pm:1683] line 74.
main::__ANON__[(eval 11)[/home/con/perl5/perlbrew/perls/perl-5.36.0/lib/5.36.0/Fatal.pm:1683]:86](GLOB(0x55adfa96ebf8)) called at mwe.pl line 13
Command exited with non-zero status 255
Run Code Online (Sandbox Code Playgroud)
但是,如果我注释掉last
代码运行没有问题,但是文件很大,这会在运行时间上产生显着差异。
如果我删除该代码也可以工作,close $view
但这close …