Xavier Noria wrote:
In Perl data estructures can only store scalar values. That's why references are used to emulate nested structures:

    $hash{$key}[0] = [EMAIL PROTECTED]; # note that @s are arrays, not lists
    $hash{$key}[1] = $string;
    $hash{$key}[2] = \%hash;

There are some pages in the documentation about nested estructures, have a glance at perldsc for instance.

An alternative would be:
  $hash{$key}[0] = [ @array ];
and
  $hash{$key}[2] = { %hash };

Here you are making a copy of the the array and hash. In the above, if you change @array or %hash, then the contents of $hash{$key}[0] and $hash{$key}[2] also change. It depends in what you want; sometimes you want it one way, sometimes the other.

Also you could have written:
  $hash{$key}[1] = \$string;
So that when $string changes, $hash{$key}[1] also changes.


--

Just my 0.00000002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to