Ken Perl wrote:
I find a difficulty when writing the constructor which may has dynamic and non fixed number of properties, say we want to construct a new class Account, package Account; sub new { my $class = shift; my $self = { currency_us=>undef, currency_fr =>undef, }; bless $self, $class; return $self; } If we want to create new object with more other contries' currency and don't want to modify the code, for example, get more other contries' name from database, how to write my constructor method and it can live with the dynamic database?
I'm unclear what you want. I don't see how you an do anything without modifying the code. Do you mean you want to subclass Account? Suppose you have a list of currencies in @currencies (I can't explain how to get it there as I don't know where it's coming from) you can add these to your object with: my @currencies = qw/ currency_uk currency_gr currency_sp /; @[EMAIL PROTECTED] = (); Does this help at all? Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>