Woops - meant to write "anonymous array" literal.  $foobar will be a
reference to the anonymous array that contains ('foo', 'bar').  - John

On Sat, Nov 28, 2009 at 6:03 AM, John Refior <jref...@gmail.com> wrote:

> Just replying to add that you can use square brackets for an array literal:
>
>
> $foobar = ['foo', 'bar'];
>
> See http://perldoc.perl.org/perlref.html#Making-References .
>
> John
>
>
> On Sat, Nov 28, 2009 at 5:53 AM, John W. Krahn <jwkr...@shaw.ca> wrote:
>
>> Mark_Galeck wrote:
>>
>>> Why does
>>>
>>> $foobar = \("foo", "bar");
>>> print $$foobar;
>>>
>>>
>>> print "bar"  ??
>>>
>>> Thank you for any insight.  Mark
>>>
>>
>> Because \("foo", "bar") is really (\"foo", \"bar") and the comma operator
>> in scalar context will return the last item listed so:
>>
>> $foobar = \("foo", "bar");
>>
>> Is just:
>>
>> $foobar = \"bar";
>>
>>
>>
>>
>> John
>> --
>> The programmer is fighting against the two most
>> destructive forces in the universe: entropy and
>> human stupidity.               -- Damian Conway
>>
>>
>> --
>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
>> For additional commands, e-mail: beginners-h...@perl.org
>> http://learn.perl.org/
>>
>>
>>
>

Reply via email to