[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Perl question on Arrays
- Subject: [ale] Perl question on Arrays
- From: fletch at phydeaux.org (Fletch)
- Date: Sat Jun 12 19:27:06 2004
- In-reply-to: <1086979923.15781.75.camel@reddwarf> (Josh Freeman's message of "Fri, 11 Jun 2004 14:52:03 -0400")
- References: <1086979923.15781.75.camel@reddwarf>
>>>>> "Josh" == Josh Freeman <josh at catea.org> writes:
Josh> I have two arrays that are both two dimensional. I assign
Josh> @foo=[some][multidimensional][array];
Arrays in perl are always one dimensional. You have an array which
contains references to arrays.</pedant>
If you want to get out a lower level array, you just use @{} to
dereference the apropriate arrayref.
@foo = @{ $bar->[23]->[42] };
Keep in mind that this makes a copy of the contents of the array
referenced by what's in $bar->[23]->[42] and modifying (say) $foo[0]
will not do anything to $bar->[23]->[42]->[0] (to do that you'd want
to instead do: $foo = $bar->[23]->[42]; $foo->[0] += 17).
See perldoc perlreftut, perldoc perllol, and perldoc perldsc.
--
Fletch | "If you find my answers frightening, __`'/|
fletch at phydeaux.org | Vincent, you should cease askin' \ o.O'
| scary questions." -- Jules =(___)=
| U