Perl, dereference array of references

后端 未结 1 1604
慢半拍i
慢半拍i 2021-02-08 23:03

In the following Perl code, I would expect to be referencing an array reference inside an array

#!/usr/bin/perl

use strict;
use warnings;

my @a=([1,2],[3,4]);
         


        
相关标签:
1条回答
  • 2021-02-09 00:03

    This stuff is tricky.

    @$a[0] is parsed as (@$a)[0], dereferencing the (undefined) scalar $a

    You wanted to say @{$a[0]}.

    0 讨论(0)
提交回复
热议问题