我正在尝试在OS X 10.6上安装Rakudo Star,并且我已经达到了令人沮丧的地步,我的构建失败了,我不知道如何处理.这里有没有人知道这个过去的方法?(我正在尝试将其设置为编写一些本地perl6程序,所以我不确定规则是否在服务器故障或堆栈溢出时需要这个,请根据需要打我)
我已经下载了提供的发行版并运行了
make VERSION=2010.07
要在文件夹中成功创建实际分发
rakudo-star-2010.07
对于任何感兴趣的人,我需要获取gnu find的端口版本(安装到/ opt/local/bin/gfind),然后将我的常规find替换为gfind.OS X发现缺少-printf选项.
顺便说一句,按照我的说法,我
$ cd rakudo-star-2010.07 $ perl Configure.pl --gen-parrot
这突然间有一段时间,但后来保释如下
/Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/pmc/timer.dump /Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/pmc/undef.dump /Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/pmc/unmanagedstruct.dump /Users/alanstorm/Downloads/rakudo-star-7652a0b/rakudo-star-2010.07/install/src/parrot/2.6.0/vtable.dump Finished install_dev_files.pl Reading configuration information from install/bin/parrot_config ... ===SORRY!=== Parrot revision r48225 required (currently r0) To automatically build the version of Parrot that came with this distribution (), try re-running Configure.pl with the '--gen-parrot' option. Or, use the '--parrot-config' option to explicitly specify the location of parrot_config to be used to build …
我正在尝试解析csv文件以执行简单的操作:提取姓氏,ID和生日,并将生日格式从m/d/yyyy更改为yyyymmdd.
(1)我在生日时使用了命名捕获,但似乎没有调用命名的捕获方法来制作我想要的东西.
(2)继承语法动作方法似乎不适用于命名捕获.
我做错了什么?
my $x = "1,,100,S113*L0,35439*01,John,JOE,,,03-10-1984,47 ELL ST #6,SAN FRANCISCO,CA,94112,415-000-0000,,5720,Foo Bar,06-01-2016,06-01-2016,Blue Cross,L,0,0";
# comma separated lines
grammar insurCommon {
regex aField { <-[,]>*? }
regex theRest { .* }
}
grammar insurFile is insurCommon {
regex TOP { <aField> \,\, # item number
<aField> \, # line of business
<aField> \, # group number
<ptID=aField> \, # insurance ID,
<ptLastName=aField> \, # last name,
<aField> \,\,\, # first name
<ptDOB=aField> \, # birthday
<theRest> }
}
# change …Run Code Online (Sandbox Code Playgroud) 我试图忽略所有带引号的行,不知何故它是一种onfusing:
> my $y='\"\""';
\"\""
> so $y ~~ m/<-[\"]>/
True # $y has a " mark, so I want it to be False
> $y ~~ m/<-[\"]>/
?\?
> $y ~~ m:g/<-[\"]>/
(?\? ?\?)
> $y ~~ m:g/<-["]>/
(?\? ?\?)
$y ~~ m/<-[\\]>/
?"?
> $y ~~ m/<-[\\\"]>/
False
Run Code Online (Sandbox Code Playgroud)
< - [\"]>与< - ["]>相同吗?
> say '"in quotes"' ~~ / '"' <-[ " ]> * '"'/;
?"in quotes"?
> say 'no "foo" quotes' ~~ / <-[ " ]> + …Run Code Online (Sandbox Code Playgroud) 在Racket Scheme中,有一个称为"字符串端口"的数据结构,您可以从中读取数据.perl6中有类似的东西吗?例如,我想实现这些结果:
my $a = "(1,2,3,4,5)"; # if you read from $a, you get a list that you can use;
my $aList=readStringPort($a);
say $aList.WHAT; # (List)
say $aList.elems; # 5 elements
my $b = "[1,2,3]"; # you get an array to use if you read from it;
my $c = "sub ($one) {say $one;}";
$c("Big Bang"); # says Big Bang
Run Code Online (Sandbox Code Playgroud)
EVAL功能并不能完成所有任务:
> EVAL "1,2,3"
(1 2 3)
> my $a = EVAL "1,2,3"
(1 2 3)
> $a.WHAT
(List)
> …Run Code Online (Sandbox Code Playgroud) 我正在与Laurent Rosenfeld一起阅读Think Perl 6, 最近与Allen B. Downey一起读这本书非常不错。
它的.tex文件在github 此处提供。
为此,我们必须对上述存储库中包含的所有.tex文件进行批处理。为此,我们必须转换乳胶代码:
\begin{verbatim}
say 42 == 42; # True
say 42 == 42.0; # True
say 42 === 42; # True
say 42 === 42.0; # False
\end{verbatim}
\begin{verbatim}
$x eq $y # $x is string-wise equal to $y
$x ne $y # $x is string-wise not equal to $y
$x gt $y # $x is greater than $y (alphabetically after) …Run Code Online (Sandbox Code Playgroud) #The @url.elems >= 10000
for @url -> $url {
start {
say $url;
sleep(1);
}
}
Run Code Online (Sandbox Code Playgroud)
如何控制线程数?
我创建了一个简单的测试模块./mods/My/Module.pm6:
unit module My::Module;
use v6;
sub hello () is export {
say "Hello";
}
Run Code Online (Sandbox Code Playgroud)
然后,我有一个测试脚本./p.p6:
#! /usr/bin/env perl6
use v6;
use My::Module;
My::Module::hello();
Run Code Online (Sandbox Code Playgroud)
然后我设置PERL6LIB包含该文件夹./mods,然后运行脚本:
$ ./p.p6
Could not find symbol '&hello'
in block <unit> at ./p.p6 line 7
Run Code Online (Sandbox Code Playgroud)
但是,如果我替换My::Module::hello()脚本中的行,hello()它可以正常工作.我在这里错过了什么?
应该很简单,但我无法应付它.
我想匹配与as 完全相同的bs数.所以,以下
my $input = 'aaabbbb';
$input ~~ m:ex/ ... /;
Run Code Online (Sandbox Code Playgroud)
应该产生:
aaabbb
aabb
ab
Run Code Online (Sandbox Code Playgroud)
UPD:以下变种不起作用,可能是因为@ smls的答案中:ex提到的bug (但更可能是因为我犯了一些错误?):
> my $input = "aaabbbb";
> .put for $input ~~ m:ex/ (a) * (b) * <?{ +$0 == +$1 }> /;
Nil
> .put for $input ~~ m:ex/ (a) + (b) + <?{+$0 == +$1}> /;
Nil
Run Code Online (Sandbox Code Playgroud)
这个,:ov和?,工作:
> my $input = "aaabbbb";
> .put for $input ~~ m:ov/ …Run Code Online (Sandbox Code Playgroud) 检查是否将无效参数传递给构造函数方法的最简单方法是什么new?
use v6;
unit class Abc;
has Int $.a;
my $new = Abc.new( :b(4) );
Run Code Online (Sandbox Code Playgroud) 我试图使用Perl5在Perl6中并行运行一系列Shell命令。Parallel::ForkManager
这几乎是Perl5工作代码的准确翻译。
CONTROL {
when CX::Warn {
note $_;
exit 1;
}
}
use fatal;
role KeyRequired {
method AT-KEY (\key) {
die "Key {key} not found" unless self.EXISTS-KEY(key);
nextsame;
}
}
use Parallel::ForkManager:from<Perl5>;
sub run_parallel (@cmd) {
my $manager = Parallel::ForkManager(8).new();
for (@cmd) -> $command {
$manager.start and $manager.next;
my $proc = shell $command, :out, :err;
if $proc.exitcode != 0 {
put "$command failed";
put $proc.out.slurp;
put $proc.err.slurp;
die;
}
$manager.finish;
}
$manager.wait_all_children;#necessary after all lists
}
my …Run Code Online (Sandbox Code Playgroud) perl6 ×10
raku ×3
capture ×1
class ×1
compilation ×1
configure ×1
constructor ×1
eval ×1
grammar ×1
inheritance ×1
latex ×1
module ×1
named ×1
negation ×1
rakudo ×1
rakudo-star ×1
regex ×1
string ×1