Perl, dereference array of references

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-06-03T20:36:04Z Indexed on 2010/06/03 20:44 UTC
Read the original article Hit count: 239

Filed under:
|
|

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]);

my @b = @$a[0];

print $b[0];

However it doesn't seem to work. I would expect it to output 1.

@a is an array of references

@b is $a[1] dereferenced (I think)

So what's the problem?

© Stack Overflow or respective owner

Related posts about perl

Related posts about array