小编Eli*_*sen的帖子

perl6/rakudo:perl6默认启用"autoflush"吗?

#!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"我不会得到这种行为.

stdout perl6 rakudo-star autoflush raku

5
推荐指数
1
解决办法
227
查看次数

perl5库是否可以在perl6中导入?

我知道perl6将定义允许导入perl5代码,但我无法做到这一点.

这是perl6 代码

use perl5:Net::FTP;
Run Code Online (Sandbox Code Playgroud)

它报告错误

是否存在配置问题或尚未准备好?

perl perl6 raku

5
推荐指数
1
解决办法
507
查看次数

perl6中方法声明中的含义是什么?

Perl6中方法声明中的加号意味着什么?

这是spec的一个例子

submethod BUILD (+$tail, +@legs, *%extraargs) {
    $.tail = $tail;
    @:legs = @legs; 
}
Run Code Online (Sandbox Code Playgroud)

perl6 raku

5
推荐指数
2
解决办法
232
查看次数

使用Perl6处理大型文本文件太慢。(2014-09)

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,感谢SE Answers和IRC @ freenode#perl6的许多建议

代码(目前为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)

text large-files perl6 raku

5
推荐指数
1
解决办法
427
查看次数

将角色混合成可调用角色

从理论上讲,您可以在运行时将角色混合到对象中.所以我试图用一个函数做到这一点:

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 CallableArgable(把自己回来之后)会导致同样的错误.可以这样做吗?怎么想?

mixins perl6

5
推荐指数
1
解决办法
71
查看次数

如何在shell函数中转义引号?

这是基于实现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 …

perl6 raku

5
推荐指数
1
解决办法
97
查看次数

创建并填充Raku对象数组?

我选择在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] = <
        &#9814; &#9816; &#9815; &#9813; &#9812; &#9815; &#9816; &#9814;
    >;
    my Str @codeptsOfPieces[$size] = (
        "\x2656", "\x2658", "\x2657", "\x2655",
    );
    has Str …
Run Code Online (Sandbox Code Playgroud)

raku

5
推荐指数
1
解决办法
139
查看次数

为什么梳子在循环内表现不同?

注意:我正在使用这是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)

raku

5
推荐指数
1
解决办法
71
查看次数

Rakudo Star 捆绑包 2022.02 构建失败

如果这个问题应该出现在更合适的论坛中,请指出我。谢谢。

我正在尝试升级到 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,但同样失败。

build raku

5
推荐指数
0
解决办法
124
查看次数

如果我不在 BEGIN 块中放置“require Module”代码,会发生什么情况?

不将条件模块加载放在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)

require raku

5
推荐指数
0
解决办法
100
查看次数

标签 统计

raku ×9

perl6 ×6

autoflush ×1

build ×1

large-files ×1

mixins ×1

perl ×1

rakudo-star ×1

require ×1

stdout ×1

text ×1