Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am getting into a tangle trying extract the days, months and years from @intersect
I would like to achieve the following:
year1 month followed by list of days
next month followed by list of days
year2 month followed by list of days
etcetera
I was working along the lines of:But I cannot extract myself from this morass, which is why I now seek your kind advice.my $pname; my @booked; my $daysb; my @yeara; my @yearb; foreach my $item (@intersect) { my ($year,$month,$day) = Add_Delta_Days(1,1,1, $item - 1); if ($year == $y) { push (@yeara, $item); } elsif ( $year == ($y + 1) ) { push (@yearb, $item); } else { print 'Sorry, the search period is too long - please go back a +nd try again'; exit; } } my %seen = (); my %cmyears; my %cmmonths; my @months_in_year = (); my @days_in_month = (); my %cmdays; my %yeara = (); @yeara = sort (@yeara); foreach my $item (@yeara) { my ($year,$month,$day) = Add_Delta_Days(1,1,1, $item - 1); $cmmonths{$item} = $month; push (@months_in_year, $month); } while ( my ($key, $value) = each (%cmmonths) ) { foreach my $item (@months_in_year) { if ($item == $value) { my ($year,$month,$day) = Add_Delta_Days(1,1,1, $key - 1); push (@days_in_month, $day); } } $cmdays{$key} = \@days_in_month; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: putting dates int year, month date
by Skeeve (Parson) on Oct 18, 2005 at 11:51 UTC | |
by Anonymous Monk on Oct 18, 2005 at 12:07 UTC | |
by Skeeve (Parson) on Oct 18, 2005 at 12:13 UTC | |
by Anonymous Monk on Oct 18, 2005 at 19:00 UTC | |
by fishbot_v2 (Chaplain) on Oct 18, 2005 at 12:16 UTC |