Peter,

Thank you for your very useful response. It seems to have addressed the
@data problem but I'm still having a problem with $model[$i] not printing or
holding a value. May I pick your brain once more?

-----Original Message-----
From: Peter Cornelius [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 30, 2001 11:45 AM
To: 'Camilo Gonzalez'; '[EMAIL PROTECTED]'
Subject: RE: Hash of hashes


>This is the code that fails me:
>  
>               $i=0;
>           for $fields(split /&/, @data) {         
>               ($key, $value) = split /=/, $fields;
>               $bigData{$model[$i]}{$key} = "$value";
>               $i++;
>           }
>  
> It won't print out @data or @model from anywhere inside the 
> for loop and
> won't print out specific dereferencing like "$bigData{307}{Price}. 
>  
> Any ideas anyone?

Hmmm.  I think split takes a string, or expression that evaluates to a
string, in its second argument.  That would mean that @data is being
evaluated in a scalar context.  When you evaluate an array in scalar context
you get the size, so you end up only looping once and only operating on an
integer (because the split would return the whole string since '&' is
nowhere in it).  You could probably do this my nesting this in another
loop...

        for $datum (@data) {
               $i=0;
           for $fields(split /&/, $datum) {         
               ($key, $value) = split /=/, $fields;
               $bigData{$model[$i]}{$key} = "$value";
               $i++;
           }
        }

I haven't run this so be ware.

Hope this helps,
Peter C.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to