On Sunday, May 12, 2002, at 08:12 , Jonathan E. Paton wrote:

first a quick clarification my posting after your original note,
sorry we were in flight concurrently,

        I suck, You RULE!

and MAJOR points on the explanation of the delta in the methods.

>> may I recommend that you start with trying say:
>>
>>      $hash{1} = [@array1];
>>
>> or
>>      my %hash = (
>>              1 => [@array1],
>>              2 => [@array2],
>>      );

Thanks for calling out the distinction...  I normally
only do the 'box the array' if I want to toss it back,
say from a sub function... I think I am coming to find
the deferencing tricks simply cooler and easier to cope with.

> Be aware there is a difference between:
>
> [@array1]
>
> and:
>
> \@array
>
> because the former flattens the array, and then takes a
> reference to a NEW array.  This can be useful, but be
> careful if you think that's enough to clone the array...
> it's not.  E.g.
>
> my $array = [["test", "elements"], "third"];
>
> print $array[0][0];
> $array[0][0] = "retest";
> print $array[0][0];
>
> Almost always you want to store a reference to the original
> array, it will be quicker.  Just be VERY careful when
> modifying these complex datastructures in Perl, you might
> change more than you realise (actually, this occurs in most
> languages).

No modification to a data structure ever goes unpunished!


ciao
drieux

---


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

Reply via email to