DJ_AM_Juicebox
asked on
length() context question with array
Hi,
Trying to figure out how perl interprets some statements. I've got this:
my @array = 1,2,3,4,5,6,7,8,9,10,11;
print(length(@array));
# prints "1"
If I put parenthesis around the assignment:
my @array = (1,2,3,4,5,6,7,8,9,10,11);
it will print "2". The second version makes sense to me, the first doesn't - how is perl interpreting that first array assignment, the one without parenthesis? Is it just assigning the first element as the entire contents of the array, and ignoring the rest of the numbers? What happens to them, they just disappear?
Thanks
Trying to figure out how perl interprets some statements. I've got this:
my @array = 1,2,3,4,5,6,7,8,9,10,11;
print(length(@array));
# prints "1"
If I put parenthesis around the assignment:
my @array = (1,2,3,4,5,6,7,8,9,10,11);
it will print "2". The second version makes sense to me, the first doesn't - how is perl interpreting that first array assignment, the one without parenthesis? Is it just assigning the first element as the entire contents of the array, and ignoring the rest of the numbers? What happens to them, they just disappear?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER