in reply to Critique
"it just seems long and not very neat"
I feel the opposite. Your code is neat and I like it. The logic is clear, easy to understand and easy to maintain. You have a good coding style.
Is it too long? No. You don't predetermine the size of your code. As long as it does the right thing in the right way, whatever it is long or short, that is the right size.
Although it is just a piece of demo code, I somehow would like it to be able to handle leap year:
sub get_days { if($curr_mon =~ /$three_one/) { return 31; } elsif($curr_mon =~ /$three_zero/) { return 30; } elsif($curr_mon == 2) { if (is_leap_year()) { return 29; } else { return 28; } } else { die "Bad month entered!\n"; } } sub is_leap_year { my (undef, undef, undef, undef,undef, $year) = localtime(time); $year += 1900; return 1 if ($year % 400 == 0); return 0 if ($year % 100 == 0); return 1 if ($year % 4 == 0); return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Critique
by phenom (Chaplain) on Dec 06, 2003 at 03:24 UTC | |
by xenchu (Friar) on Dec 06, 2003 at 06:01 UTC | |
by phenom (Chaplain) on Dec 06, 2003 at 14:35 UTC | |
|
Re: Re: Critique
by ihb (Deacon) on Dec 06, 2003 at 10:59 UTC | |
by phenom (Chaplain) on Dec 06, 2003 at 14:39 UTC | |
|
Re: Re: Critique
by ysth (Canon) on Dec 08, 2003 at 00:19 UTC | |
|
Re: Re: Critique
by Paulster2 (Priest) on Dec 07, 2003 at 14:09 UTC |