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

Re: [MacPerl] Re: Some suggestions



On Thu, May 20, 1999 at 06:42:38AM -0400, Allan Greenier wrote:
> So is this syntax correct:
> 
> %Models =
> 
> (model1 => ['vendor1',family1,model1html],
>  model2 => ['vendor2',family2,model2html])
> 
> and
> 
> for each $model keys(%Models)
> ($vendor,$family,$modelhtml) = $model
> 
> or is it
> for each @model keys(%Models)
> ($vendor,$family,$modelhtml) = @model
> 

Actually, it's neither of those.  You forgot to get the value from the hash.

($vendor,$family,$modelhtml) = $Models{$model};

Not there yet....  This assigns the value for that key, which is an array
ref, to $vendor.  $family and $modelhtml will be undefined.

($vendor,$family,$modelhtml) = @{$Models{$model}};

This dereferences the array ref, and the resulting list is assigned to your
list of scalars.

Ronald

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org