Reputation: 606
I have a perl array I need to store in the following way:
$self->{spec}->{allImages} = @allImages;
Then I need to retrieve the contents later:
print Dumper($self->{spec}->{allImages});
This yields:
$VAR1 = 10;
(the number of items in the array).
How can I break out of scalar context and get $self->{spec}->{allImages} back as a list?
Upvotes: 0
Views: 83
Reputation: 754030
You need to change the assignment:
$self->{spec}->{allImages} = \@allImages;
This creates an array-ref that you can use.
Upvotes: 1
Reputation: 93676
Each hash value can only be a scalar.
You must store a reference to the array:
$self->{spec}->{allImages} = \@allImages;
http://perldoc.perl.org/perlreftut.html will give you more tutorial.
Upvotes: 9