in reply to Array of Arrays: why is "$VAR1->[0][1]" and the like embedded within?
Since your code that creates @a basically references elements of existing tuples (which now are references), perl does not create NEW references .. it uses existing addresses of these items.
This is what Dumper tries to show you - some elements reference things inside yourself!
The actual values generated are indeed proper tuples the way you expect .. they just happen to be references to existing stuff.
FYI - the "increment" sub could be condensed to a single statement:
return [ map {[$d->[$_-1],$d->[$_]]} 1..$#$d ];
Memory fault -- brain fried
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array of Arrays: why is "$VAR1->[0][1]" and the like embedded within?
by Athanasius (Archbishop) on Jun 11, 2018 at 04:15 UTC | |
by NetWallah (Canon) on Jun 11, 2018 at 04:24 UTC | |
by Athanasius (Archbishop) on Jun 11, 2018 at 05:41 UTC | |
by corenth (Monk) on Jun 11, 2018 at 15:32 UTC | |
by corenth (Monk) on Jun 11, 2018 at 15:26 UTC | |
|
Re^2: Array of Arrays: why is "$VAR1->[0][1]" and the like embedded within?
by corenth (Monk) on Jun 11, 2018 at 15:22 UTC |