in reply to Re^3: how to code a class and use it with hash of hash as data member?
in thread how to code a class and use it with hash of hash as data member?

The purpose of using $self is so that you can have more than one object, each with its own member data. The original code allowed people to create multiple objects, but each accessed the same hash. I don't see any real reason to use objects in that case.

My $self doesn't access %serverMap. Each object gets its own copy of that data.

I changed my constructor to throw out unnecessary code and to allow inheritance by using the two-argument form of bless, which is almost always the right thing to do.

My code doesn't create a singleton, but I wasn't sure if you needed that.

Replies are listed 'Best First'.
Re^5: how to code a class and use it with hash of hash as data member?
by edwardt_tril (Sexton) on Mar 17, 2006 at 20:17 UTC
    hi i get an compile error in
    my %self = %{ $serverMap{ default } }, @_;
    error is "Useless use of variable in void context".
    I think it is complaining about @_? but not quite
    sure what it means .. i guess the code tried to set %self
    to default if people don't enter a hash of hash as part of new. should that be
    %{ $serverMap{ default } } || @_
    ?? thanks