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.
- 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.
- 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);
- 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--
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.