#!perl6
use v6;
my $message = "\nHello!\n\nSleep\nTest\n\n";
my @a = $message.split( '' );
for @a {
sleep 0.3;
.print;
}
Run Code Online (Sandbox Code Playgroud)
Perl6默认启用"autoflush".使用perl5而不启用"outflush"我不会得到这种行为.
我知道perl6将定义允许导入perl5代码,但我无法做到这一点.
这是perl6 代码
use perl5:Net::FTP;
Run Code Online (Sandbox Code Playgroud)
它报告错误
是否存在配置问题或尚未准备好?
Perl6中方法声明中的加号意味着什么?
这是spec的一个例子
submethod BUILD (+$tail, +@legs, *%extraargs) {
$.tail = $tail;
@:legs = @legs;
}
Run Code Online (Sandbox Code Playgroud) https://github.com/yeahnoob/perl6-perf中的代码托管,如下所示:
use v6;
my $file=open "wordpairs.txt", :r;
my %dict;
my $line;
repeat {
$line=$file.get;
my ($p1,$p2)=$line.split(' ');
if ?%dict{$p1} {
%dict{$p1} = "{%dict{$p1}} {$p2}".words;
} else {
%dict{$p1} = $p2;
}
} while !$file.eof;
Run Code Online (Sandbox Code Playgroud)
当“ wordpairs.txt”较小时,运行良好。
但是,当“ wordpairs.txt”文件约为140,000行(每行,两个单词)时,它运行的非常慢。即使运行20秒,它也无法完成。
有什么问题吗?代码中是否有错误?感谢任何人的帮助!
代码(目前为2014-09-04):
my %dict;
grammar WordPairs {
token word-pair { (\S*) ' ' (\S*) "\n" }
token TOP { <word-pair>* }
}
class WordPairsActions {
method word-pair($/) { %dict{$0}.push($1) }
}
my $match = WordPairs.parse(slurp, :actions(WordPairsActions)); …Run Code Online (Sandbox Code Playgroud) 从理论上讲,您可以在运行时将角色混合到对象中.所以我试图用一个函数做到这一点:
my &random-f = -> $arg { "Just $arg" };
say random-f("boo");
role Argable {
method argh() {
self.CALL-ME( "argh" );
}
}
&random-f does Argable;
say random-f.argh;
Run Code Online (Sandbox Code Playgroud)
在角色中,我self用来引用已经定义的函数,并CALL-ME实际调用角色中的函数.但是,这会导致以下错误:
Too few positionals passed; expected 1 argument but got 0
in block <unit> at self-call-me.p6 line 5
Run Code Online (Sandbox Code Playgroud)
我真的不知道谁会期待一个论点.从理论上讲,它应该是CALL-ME功能,但谁知道.消除self.产量的不同错误:CALL-ME used at line 11.添加does Callable到Argable(把自己回来之后)会导致同样的错误.可以这样做吗?怎么想?
这是基于实现Perl 6.d的MoarVM版本2019.03构建的Rakudo Star版本2019.03.1。
Windows 10
例子:
1)错误:
shell 'mysqldump -uroot -ppassword asppmr > D:\b\29-09-2019 19-45-18\asppmr.sql';
Run Code Online (Sandbox Code Playgroud)
mysqldump:[警告]在命令行界面上使用密码可能不安全。mysqldump:找不到表:“ 19-45-18 \ asppmr.sql” Proc.new(in => IO :: Pipe,out => IO :: Pipe,err => IO :: Pipe,exitcode => 6,信号=> 0,pid => 11928,命令=>(“ mysqldump -uroot -ppassword asppmr> D:\ b \ 29-09-2019 19-45-18 \ asppmr.sql”))
2)错误:
shell 'mysqldump -uroot -ppassword asppmr > "D:\b\29-09-2019 19-45-18\asppmr.sql"';
Run Code Online (Sandbox Code Playgroud)
??????????????? ?????? ??????? ??????,????? ?????? ??? ?????? ????。Proc.new(in => IO :: Pipe,out => IO :: Pipe,err => IO :: Pipe,exitcode => 1,信号=> 0,pid …
我选择在Perl 6中重新设计我的先前代码的一部分,在这种情况下,是棋盘。前两节课进展顺利(或者至少工作了,我知道的很少,我无法说出它们的正确性) ,但我坚持使用第三个。这是代码:
#!/home/hsmyers/rakudo741/bin/perl6
# board.p6 - Beginnings of a PGN toolset. And place to start learning
# Perl 6/Raku.
use v6d;
#!___________________________________________________________
constant $size = 4;
class Piece {
my Str @namesOfPieces[$size] = <
white-rook white-knight white-bishop white-queen
>;
my Str @abrevsOfPieces[$size] = <
R N B Q K B N R
>;
my Str @symbolsOfPieces[$size] = <
♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
>;
my Str @codeptsOfPieces[$size] = (
"\x2656", "\x2658", "\x2657", "\x2655",
);
has Str …Run Code Online (Sandbox Code Playgroud) 注意:我正在使用这是Rakudo Star版本2019.03.1在REPL上进行所有操作,这是在实现Perl 6.d的MoarVM版本2019.03上构建的Rakudo Star版本2019.03.1。
在euler项目#22中,有一个names.txt文件,类似于“ JERE”,“ HAI”,“ ELDEN”,“ DORSEY”,“ DARELL”,“ BRODERICK”,“ ALONSO”,...
当我读到它时,将其拆分和排序,即可得到我所期望的名称列表。
for '../names.txt'.IO.slurp.split(',').sort -> $name {
say $name;
}
Run Code Online (Sandbox Code Playgroud)
打印出来
...
"ZONIA"
"ZORA"
"ZORAIDA"
"ZULA"
"ZULEMA"
"ZULMA"
Run Code Online (Sandbox Code Playgroud)
现在,如果我添加 comb()
for '../names.txt'.IO.slurp.split(',').sort -> $name {
say $name.comb;
}
Run Code Online (Sandbox Code Playgroud)
我越来越
...
(" Z O N I A ")
(" Z O R A ")
(" Z O R A I D A ")
(" Z U L A ")
(" Z U L E M A ")
(" Z U …Run Code Online (Sandbox Code Playgroud) 如果这个问题应该出现在更合适的论坛中,请指出我。谢谢。
我正在尝试升级到 Star Bundle 2022.02,但失败了。我觉得尝试调整源代码对我来说太麻烦了。解决办法是什么?
我下载了 tar 球并解压了它;然后跑了
./bin/rstar install
Run Code Online (Sandbox Code Playgroud)
错误是:
[2022-03-12T23:18:15] [INFO] Installing Raku in /home/lisprog/Perl6/rakudo-star-2022.02
[2022-03-12T23:18:15] [INFO] Starting build on MoarVM
[2022-03-12T23:18:15] [NOTIC] Using /home/lisprog/Perl6/rakudo-star-2022.02/tmp/tmp.qVxYSNmS0X as working directory
[2022-03-12T23:18:15] [NOTIC] Build log available at /home/lisprog/Perl6/rakudo-star-2022.02/tmp/tmp.819bVtG6xv
[2022-03-12T23:20:30] [INFO] Starting build on NQP
[2022-03-12T23:20:30] [NOTIC] Using /home/lisprog/Perl6/rakudo-star-2022.02/tmp/tmp.JQlrQlVRgO as working directory
cp: cannot stat '/home/lisprog/Perl6/rakudo-star-2022.02/src/nqp-2022.024/nqp-2022.024/.': No such file or directory
[2022-03-12T23:20:30] [ALERT] Build failed!
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用git和curl,但同样失败。
不将条件模块加载放在BEGIN块中有什么问题吗?如果没有BEGIN块,在预编译后更改环境变量仍然会影响加载哪个模块。
my $table;
#BEGIN {
if %*ENV<TABLE_A> {
require MY_TABLE_A <&get_table>;
$table = get_table();
}
else {
require MY_TABLE_B <&get_table>;
$table = get_width();
}
#}
Run Code Online (Sandbox Code Playgroud)