APM: arrays and hashes

Brian Michalk michalk at awpi.com
Tue Sep 21 12:52:12 CDT 2004


I'm having problems making a hash reference to a 2D array.

I would like to get the following output:

  DB<40> x @res
0  'hello'
1  'there'
2  'world'

  DB<45> x $self->{'ary'}
0  ARRAY(0x8cfd1f0)
   0  'hello'
   1  'there'
   2  'world'
1  ARRAY(0x8cf2ab0)
   0  'hello'
   1  'there'
   2  'world'
2  ARRAY(0x8cd385c)
   0  'hello'
   1  'there'
   2  'world'

One would think one could get it like this:
  DB<43> push @{$self->{'ary'}}, [@res]
  DB<43> push @{$self->{'ary'}}, [@res]
  DB<43> push @{$self->{'ary'}}, [@res]


However, the above generates the following:
  DB<52> x $self->{'ary'}              
0  ARRAY(0x8cfc4e8)
   0  ARRAY(0x8cfc494)
      0  'hello'
      1  'there'
      2  'world'
   1  ARRAY(0x8cfce30)
      0  'hello'
      1  'there'
      2  'world'
   2  ARRAY(0x8cfd0d0)
      0  'hello'
      1  'there'
      2  'world'

Which is a 3D array, and I can't figure out how to get it to work correctly.


More information about the Austin mailing list