in reply to The philosophy behind element reference syntax

It's all changing the context you are in, you can reference an element as @foo[$i] or $foo[$i], it's just an array slice of one (Ie. array context) versus a single element (scalar context). Eg.

my @abcd = (1,2,3); print "@abcd" . "\n"; $abcd[0] = 4; @abcd[1] = 5; print "@abcd" . "\n"; $abcd[0] = (4, 5, 6); @abcd[1] = (4, 5, 6); print "@abcd" . "\n"; print @abcd . "\n"; __DATA__ 1 2 3 4 5 3 6 4 3 3

As you can see the simple assignments are the same, it's only when you get to a point where the context matters that it changes.

--
James Antill

Replies are listed 'Best First'.
Re: Symbols are about denoting context
by revdiablo (Prior) on Dec 08, 2004 at 18:24 UTC

    Your post is mostly correct, except for a small nit that I can't help but pick -- it's called "list context," not "array context."

    I know people hate hearing this, but there is a difference between lists and arrays, and it can be rather important. It doesn't help that the context determination is made by a function called wantarray, but I think we should try our best to use the correct terminology.