Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] class specific hash in base class

Expand Messages
  • Dave Gray
    ... This should give you a good start. There s no magic (automatic) way to do that... you have to use a symbol table alias per class variable you want to
    Message 1 of 5 , Aug 24 10:10 AM
    • 0 Attachment
      > Problem:
      > In a base class B i'd like to put a big hash %H as class (not
      > instance) specific data. The hash %H must be accessible from classes
      > D1, D2,... derived from B.

      This should give you a good start. There's no magic (automatic) way to
      do that... you have to use a symbol table alias per class variable you
      want to inherit per subclass.

      Cheers,
      Dave

      __CODE__
      #!/usr/bin/perl -w
      use strict;

      package B;
      our %H = (key => 'value');

      package D1;
      our @ISA = ('B');
      *H = *B::H; # symbol table alias

      package main;

      print "[$D1::H{key}]\n";
      print "[$B::H{key}]\n";

      $B::H{key} = 'blah';

      print "[$D1::H{key}]\n";
      print "[$B::H{key}]\n";
    Your message has been successfully submitted and would be delivered to recipients shortly.