I am not a particularly strong Perl programmer, so forgive me if this is a stupid question.
What does @$ notation mean, exactly? For instance, if I wrote
I'm seeing @$ used in several places in code that I have to maintain and I can't seem to figure out how it's different from a regular list. I thought it might mean "use the array if it is an array and the scalar if not," but that wouldn't make any sense because of Perl's ability to have an array and a scalar be named the same but be two different things. It's also at odds w/ another example of its use like this:
Which is normally supposed to get the index count of the array, which seems to imply that this has to be an array of some sort.
Any help is appreciated. This is hard to google since google omits special symbols like @ and $ -_-
What does @$ notation mean, exactly? For instance, if I wrote
Code:
How is this any different than a regular array (@ by itself)? E.g.:for (@$foo) { # do stuff }
Code:
for (@foo) { # do stuff }
I'm seeing @$ used in several places in code that I have to maintain and I can't seem to figure out how it's different from a regular list. I thought it might mean "use the array if it is an array and the scalar if not," but that wouldn't make any sense because of Perl's ability to have an array and a scalar be named the same but be two different things. It's also at odds w/ another example of its use like this:
Code:
$count = @$foo
Which is normally supposed to get the index count of the array, which seems to imply that this has to be an array of some sort.
Any help is appreciated. This is hard to google since google omits special symbols like @ and $ -_-
一个大西瓜