Why can't we initialize state arrays/hashes in list context?

Viewed 2869

There is a restriction on arrays and hashes as state variables. We can't initialize them in list context as of Perl 5.10:

So

state @array = qw(a b c); #Error!

Why is it so? Why this is not allowed?

We can use state arrays and initialize them by this way

state @numbers;
push @numbers, 5;
push @numbers, 6;

but why not directly do it by state @numbers = qw(5 6);

Why doesn't Perl allow it?

5 Answers
Related