Perl › 日付・時刻 時刻の差を求めるには、まずhhmmssと表記されているものを秒に変換する必要があります。秒の差を求めた上で再度hhmmssの時刻表現に復元します。時刻の差を求めるサンプルです。 use strict; use warnings; print "(1)時刻の差を求める(24時間を越えない)\n"; my $time_str1 = '03:44:23'; my $time_str2 = '22:34:45'; # 時刻の文字列表現を時刻情報のハッシュに変換する。 my $time1 = time_from_str($time_str1); my $time2 = time_from_str($time_str2); # 時刻情報のハッシュを秒に変換して経過秒を計算 my $sec_interval = time_to_sec($time2) - time_to_sec