[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Perl Card Games



Uri Guttman wrote:
> 
> >>>>> "JP" == John Porter <jdporter@min.net> writes:
> 
>   JP>         @a = (undef) x 5;  # any value; it will get overwritten.
>   JP>         for ( @a ) {
>   JP>           @$_ = (....);
>   JP>         }
> 
> i still don't get what you expect @$_ to be? explain it in english if
> you can. it looks like a symref.

It's not a symbolic reference.  Since each element in @a is undefined,
@$_ autovivifies an array and stores a reference to it in @a.

> and your comment about any value will be overwritten makes no sense
> either.

Yes.  It has to be undef, otherwise you are creating a symbolic
reference, and as long as x is being used it would be the same reference
stored in each element of @a.

-- 
Rick Delaney
rick.delaney@home.com

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe