そのため、カレンダー ファイルを読み込んでファイルに日付を挿入していますが、日付を時系列のままにしたいと考えています。問題は、日付を入れる場所を見つけたときに発生します。ファイルは、挿入したいポイントをすでに過ぎています。
私が見ているカレンダーファイルは次のようになります。
# November 2010
11/26/2010
11/27/2010
11/28/2010
11/29/2010
11/30/2010
# December
12/24/2010
12/25/2010
12/26/2010
12/27/2010
12/28/2010
12/29/2010
12/30/2010
私のコードは次のようになります。
while (my $line = <FILE>) {
if (substr($line, 0, 1) =~ m/\#/ || $line =~ m/calendar/) { #if the line is commented out or contains the calendar's name skip to next line
next;
}
chomp($line);
my ($temp_month, $temp_day, $temp_year) = split(/\//, $line, 3);
if ($year == $temp_year && $month == $temp_month && $day < $temp_day) {
?
}
}
ファイル内の前の場所を指す方法について何か提案はありますか?