我試圖計算和顯示,以分鐘爲單位,輸入的日期和當前時間之間的差異。我有:查找兩個日期之間的時間在Perl
print "Enter a date YYYY MM DD. Remember perl's months go from 0-11.\n";
while (@dateEnt < 1) {
my $dateEntered = <STDIN>;
chomp $dateEntered;
push @dateEnt, $dateEntered;
(@datedata) = split(/\s+/, $dateEntered);
$year = $datedata[0];
$month = $datedata[1];
$day = $datedata[2];
}
$time = time;
$readabletime = localtime($time);
use Time::Local;
$timeB = localtime [1];
$timeBetween = $readabletime[1] - $timeB;
print "The time between the dates is $timeBetween\n";
當我執行此操作時,我沒有得到答案。任何幫助?
歡迎使用Stack Overflow和_perl_標記。請確保您總是在程序中添加'use strict;'和'warnings'。它們可以幫助您儘早發現錯誤。如果你從一個既不顯示也不顯示的源代碼學習Perl,它已經過時了。您最好使用SO標籤中的Perl標籤wiki。現在,你永遠不會使用你的用戶輸入的日期。還有一些語法錯誤。請以'use strict'和'使用警告'開始。 – simbabque
...和「過時」我們的意思是字面上幾十年的老。 2000年推出「使用警告」; '使用嚴格'於1994年推出。 – melpomene