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

($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";


你可能感兴趣的:(标题环境的分割返回最后一个值 (Slices in scalar context return the last item of the slice. ))