Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Data inheritance

by perlbaski (Sexton)
on Sep 23, 2011 at 20:44 UTC ( #927613=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^5: Data inheritance
by ikegami (Pope) on Sep 23, 2011 at 21:00 UTC

    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."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://927613]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-02-27 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (382 votes). Check out past polls.