#!perl6
use v6;
my $longest = 3;
my @list = <a b c d e f>;
for @list -> $element is rw {
$element = sprintf "%*.*s", $longest, $longest, $element;
$element.say;
}
这行得通。但是在第二个和第三个我收到一条错误消息。我怎样才能让他们工作?
#!perl6
use v6;
my $longest = 3;
my @list = <a b c d e f>;
for @list <-> $element {
$element = sprintf "%*.*s", $longest, $longest, $element;
$element.say;
}
# ===SORRY!===
# Missing block at line 11, near ""
.
#!perl6
use v6;
my $longest = 3;
my $list = <a b c d e f>;
for $list.list -> $element is rw {
$element = sprintf "%*.*s", $longest, $longest, $element;
$element.say;
}
# Cannot modify readonly value
# in '&infix:<=>' at line 1
# in <anon> at line 8:./perl5.pl
# in main program body at line 1