このPERL Switch..caseステートメントがあります:
switch ($today)
{
case "14-Aug-2012" { do A }
case "15-Aug-2012" { do B }
}#end switch
私の問題は、「do B」ステートメントが 2012 年 8 月 15 日から 2012 年 10 月 1 日と同じであることです。これらの日付の間のケースをどのように言えば、同じことを別の日に書き直してスクリプトを長くする必要がなくなりますか?
スクリプト全体を入れたので、質問を管理するために必要なものを誰かが使用できるようになりました。
use Date::Calc
use Switch
#connect to database...
my @date_today=Today();
my $today=substr(Date_to_Text(@date_today),4,11);
Switch($today)
{
case "14-Aug-2012" {Do A}
case "15-Aug-2012" {Do B}
case ...
case ...
case ...
}
最後の 3 つの case ステートメントは、次のようにする必要があります。
between 16-Aug-2012 and 28-Sep-2012 {do C}
between 29-Sep-2012 and 26-Oct-2012 {do D}
between 27-Oct-2012 and 09-Nov-2012 {do E}