"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;
}