我正在尝试用Perl 6编写一些类来测试Perl 6类和方法.
这是代码:
class human1 {
method fn1() {
print "#from human1.fn1\n";
}
}
class human2 {
method fn1() {
print "#from human2.fn1\n";
}
}
my $a = human1.new();
my $b = human2.new();
$a.fn1();
$b.fn1();
print "now trying more complex stuff\n";
my $hum1_const = &human1.new;
my $hum2_const = &human2.new;
my $c = $hum2_const();
$c.fn1();
Run Code Online (Sandbox Code Playgroud)
基本上我希望能够使用human1构造函数或human2构造函数来$c动态构建对象.但是我收到以下错误:
Error while compiling /usr/bhaskars/code/perl/./a.pl6
Illegally post-declared types:
human1 used at line 23
human2 used at line 24
Run Code Online (Sandbox Code Playgroud)
如何 …
我有一个Perl 6代码,我正在执行以下操作:
if ($line ~~ /^\s*#/) { print "matches\n"; }
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
===SORRY!===
Regex not terminated.
at line 2
------> <BOL>?<EOL>
Unable to parse regex; couldn't find final '/'
at line 2
------> <BOL>?<EOL>
expecting any of:
infix stopper
Run Code Online (Sandbox Code Playgroud)
这是Perl 5代码的一部分:
if ($line =~ /^\s*#/)
Run Code Online (Sandbox Code Playgroud)
它曾经很好地识别具有可选空间和a的行#.
在Perl 6中导致此错误的原因是什么?
我有一个如下的脚本。目的是采用不同的过滤方法来过滤列表。
这是代码。
2
3 class list_filter {
4 has @.my_list = (1..20);
5
6 method filter($l) { return True; }
7
8 # filter method
9 method filter_lt_10($l) {
10 if ($l > 10) { return False; }
11 return True;
12 }
13
14 # filter method
15 method filter_gt_10($l) {
16 if ($l < 10) { return False; }
17 return True;
18 }
19
20 # expecting a list of (1..10) to be the output here
21 …Run Code Online (Sandbox Code Playgroud) 我试图用Perl 6读取和更新一些MS Excel(xlsx)文件.我应该下载哪些模块?
我通过谷歌搜索看到一个Perl 6作家:
https://github.com/evanmiller/XLSX-Writer
这是用于写作的吗?
我没有看到任何特定于Perl 6的模块在XLSX中读取.是否有一些阅读模块?