in reply to Object Inheritance in Perl

Well, I have played around with this a little bit, and I don't have ALL the answers - this a quite a chunk of code!

I really hope that you are practicing OOP, and not using this in production - no offense, it's not very pretty.

  1. change the initialization of @persons in the Adres constuctor to
    'persons' => ();
    and likewise change all references to @persons to just persons - it's a key, not an array - the value of the key points to an array.

  2. In sub addPerson - you are trying to use Perl arrays like they were C arrays - get rid of your personCount method - you don't need to store the index of the last person added, push will do it for you :)
    # this is all you need to add someone push(@{$self->{persons}},$aPerson);
  3. In printProperties (around line 260) use this:
    my $size = @{$self->{persons}}; for(0..$size) { printf("\t%18.18s => $_\n", "person number"); @{$self->{persons}}[$_]->printProperties(); }
Now you should not be clobbing old users when you add new ones. Disclaimer - I still get a warning that appears to be caused by an empty element in the persons array reference - I'll leave that up to you to fix. :)

Side issues - use CGI and -w

Jeff

R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--