in reply to Re^2: Data inheritance
in thread Data inheritance

Between the two options you gave, I would go with the one that compiles.

Of course, it's not between the two options you gave. What's with using global variables, especially one that gets clobbered every time you create an object.

Replies are listed 'Best First'.
Re^4: Data inheritance
by perlbaski (Sexton) on Sep 23, 2011 at 20:44 UTC
    Is there any other way of doing this apart from using global variables. I want to have common data variables in CommonObject.pm which I want to set in child class depending upon the type of child I create.

    Also, I cannot seem to be able to set parent class variables in child class even with declaration using 'our'.

    Looks like using exporter module is the only way to go.

      Is there any other way of doing this apart from using global variables.

      Don't know. What are you doing? So far, you've only asked how to set a global variable. (You said class var, but that's the same thing.)

      Also, I cannot seem to be able to set parent class variables in child class even with declaration using 'our'

      Reread what I said: "which means you can access the array as @CommonObject::common_array from anywhere."