|Don't ask to ask, just ask|
how to make a package variable as c++by anaconda_wly (Scribe)
|on Nov 04, 2012 at 09:12 UTC||Need Help??|
anaconda_wly has asked for the
wisdom of the Perl Monks concerning the following question:
Hi, Monks: I used to use c++, but beginner for perl. I want to create a singleten class with a bunch of attributes and methods but didn't know how.
The XML structure is like:
I call code as:
As you see, I didn't know how to create and use what we say member variable in c++. The $XMLfile_name and the @hostList here is using as member variables. @hostList used for holding results parsed from the XML file.
Another question: In the new method, as I read package method always put the invoker as the first argument. I suppose 'invoker' for new() means the class MyConfig and return an instance after blessed; And the 'invoker' for loadConfig seems change to be an instance, seems the $self by te first default argument is an instance not the class any more. But as I know the 'new' is an ordinary method as others, not a keywords, why they behaves different?
The last question:I don't think I made my while condition correct. How can I deal with the while index simply using $_? Thanks a lot in advance!!