标题环境的分割返回最后一个值 (Slices in scalar context return the last item of the slice. )

来源:互联网 发布:源氏木语 知乎 编辑:程序博客网 时间:2024/05/17 09:40
($t) = qw/"a", "b"/;            # 个数不匹配,$t匹配"a"$t = qw/"a", "b"/;              # 此时$t = 后一个
my @a = qw/first second third/;my %h = (first => 'A', second => 'B');my $t = @a[0, 1];                  # $t is now 'second'my $u = @h{'first', 'second'};     # $u is now 'B'print "$t $u\n";


原创粉丝点击