Help for this page

Select Code to Download


  1. or download this
    
    $obj->[0] = 'foo';
    ...
    $obj->{'bar'} = 'bar';
    $obj->{'baz'} = 'baz';
    
  2. or download this
    
    package Class::Of::Obj;
    ...
    $obj->[$bar_idx] = 'bar';
    $obj->[$baz_idx] = 'baz';
    
  3. or download this
    
    package Super::Class;
    ...
    # Everything's hardwired up there and the Super::Class
    # isn't telling me. I'm stuck.
    
  4. or download this
    
    package Super::Class;
    ...
    # oops! NEXT_IDX() is still set to '0' up there, and we just set
    # OTHER_IDX to 1, clobbering whatever's in the BAR_IDX field!
    
  5. or download this
    
    package Super::Class;
    ...
    use constant OTHER_IDX => __PACKAGE__>SUPER::NEXT_IDX();
    #now at 3, after BAZ_IDX
    
  6. or download this
    
    package Super::Class;
    ...
    use constant DIFFERENT_IDX => __PACKAGE__>SUPER::NEXT_IDX();
    #now at 4, after OTHER_IDX
    
  7. or download this
    
    package Super::Class;
    ...
    use constant OTHER_IDX => __PACKAGE__>SUPER::NEXT_IDX();
    #now at 4, DIFFERENT THAN LAST TIME!
    
  8. or download this
    
    package Super::Class;
    ...
    use constant OTHER_IDX => __PACKAGE__->SUPER::NEXT_IDX();
    #also set to 3
    
  9. or download this
    
    package Distant::Sub::Class;
    ...
    
    #both OTHER_IDX and DIFFERENT_IDX point to index 3. Whoops.
    
  10. or download this
    
    package Super::Class;
    ...
    use constant OTHER_IDX => __PACKAGE__->SUPER::NEXT_IDX();
    #also set to 0
    
  11. or download this
    
    my $obj = Sub::Class->new();
    $obj->[CLASS_IDX]->[OTHER_IDX];