Perl 如何取消对数组的验证

Perl 如何取消对数组的验证,perl,Perl,我试图检索作为引用存储的数组的各个元素 my @list = ("three 13 3 1 91 3", "one 11 5 1 45 1", "two 12 7 1 33 2", "four 14 1 1 26 4"); my @refList = map { [$_, (split)[-1]] } @list; # see what it is in @refList use Data::Dumper; print Dumper(

我试图检索作为引用存储的数组的各个元素

my @list = ("three 13  3  1  91 3", "one   11  5  1  45 1",
            "two   12  7  1  33 2", "four  14  1  1  26 4");

my @refList = map { [$_, (split)[-1]] } @list;

# see what it is in @refList
use Data::Dumper;
print Dumper(@refList);

print "\n the value is $refList[0][0][1]";
输出

$VAR1 = [
          'three 13  3  1  91 3',
          '3'
        ];
$VAR2 = [
          'one   11  5  1  45 1',
          '1'
        ];
$VAR3 = [
          'two   12  7  1  33 2',
          '2'
        ];
$VAR4 = [
          'four  14  1  1  26 4',
          '4'
        ];

 the value is
但我需要的是

 print "\n the value is $refList[0][0][1]" as 13

如何获取值

您在打印中使用了太多的
[0]
,要引用您正在谈论的
3
值,请阅读

$refList[0][1]

我想我是疯了,我发誓我以为你刚才说的是值
3
。 虽然我看不到你的帖子有什么变化,奇怪。。我责备睡眠不足

如果您正在查找值
13
(您的帖子当前显示),您应该将代码更改为以下内容

use Data::Dumper;

my @list    = ("three 13 3 1 91 3", "one 11 5 1 45 1", "two 12 7 1 33 2", "four 14 1 1 26 4");
my @refList = map {@_=split;$_[0]=$_;[@_]} @list;

# print Dumper [@refList];

print "\n the value is ", $refList[0][1];
如果只想将每个字符串转换为数组引用,请将其用作
@refList
的声明/定义

my @refList = map {[split]} @list;

正如refp所说,您使用了太多的垃圾
[0]
,您可以:

my @list    = ("three 13 3 1 91 3", "one 11 5 1 45 1", 
               "two 12 7 1 33 2", "four 14 1 1 26 4");

my @refList = map {[split]} @list;
print "\n the value is ", $refList[0][1];
但是,如果您想拥有这3个级别,这将完成以下工作:

my @list    = ("three 13 3 1 91 3", "one 11 5 1 45 1",
               "two 12 7 1 33 2", "four 14 1 1 26 4");
my @refList = ([map {[split]} @list]);
print "\n the value is ", $refList[0][0][1];
my@refList=map{my(undef,@t)=split;[$\,@t]}@list会稍微好一点。
my @list    = ("three 13 3 1 91 3", "one 11 5 1 45 1",
               "two 12 7 1 33 2", "four 14 1 1 26 4");
my @refList = ([map {[split]} @list]);
print "\n the value is ", $refList[0][0][1];