Re: question on reference to array slice
- From: Paul Lalli <mritty@xxxxxxxxx>
- Date: Sun, 29 Jul 2007 19:22:10 -0700
On Jul 29, 6:09 pm, Mirco Wahab <wahab-m...@xxxxxx> wrote:
John W. Krahn wrote:
$data[ 0 ] = [ \@nums[ 0 .. 9 ] ];
$data[ 1 ] = [ \@nums[ 10 .. 19 ] ];
This usage of slice reference is something I
didn't consider. So Bellovins word was right
again: "any software problem can be solved by
adding another layer of indirection."
"anonymous slice reference" - thanks
for pointing me on this.
I wouldn't call it a slice reference. An array slice is a list. The
\ operator applied to a list returns a list of references of the items
in that list. That is:
my @refs = \($a, $b, $c);
is the same as
my @refs = (\$a, \$b, \$c);
So in John's example, you're assigning $data[0] to be a reference to
an array which contains references to each of the first ten elements
of @nums. There is nothing intrinsic about $data[0][2] that
identifies it as a reference to the element immediately prior to
$nums[3]. It's just a list of references to values that happened to
all come from the same array.
Paul Lalli
.
- References:
- question on reference to array slice
- From: Rick
- Re: question on reference to array slice
- From: John W. Krahn
- Re: question on reference to array slice
- From: Mirco Wahab
- question on reference to array slice
- Prev by Date: Re: question on reference to array slice
- Next by Date: Re: fork command.
- Previous by thread: Re: question on reference to array slice
- Next by thread: Re: question on reference to array slice
- Index(es):
Relevant Pages
|