문제

I am working on some perl code that is not mine. I ran into this line and I have no idea what it is doing:

my $sum = [];

I just don't understand what this scalar is being set to.

도움이 되었습니까?

해결책

[ LIST ]

is basically a shortcut for

do { my @anon = ( LIST ); \@anon }

It creates an array initialized with the result of the enclosed expression (if any), and returns a reference to that array.

다른 팁

From the documentation:

If you write just [] , you get a new, empty anonymous array. If you write just {} , you get a new, empty anonymous hash.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top