2011-07-19 38 views
0

這裏是我想要做的(沒有什麼複雜的):Perl:未定義的子程序和main :: gmdate?

use Digest::MD5 qw(md5 md5_hex md5_base64); 

$apikey = '1234'; 
$secret = '123'; 
$timestamp = gmdate('U'); 
$sig = md5($apikey . $secret . $timestamp); 

echo $sig 

所以,在$時間戳= gmdate行發生錯誤。

我在做什麼錯?

回答

3

我認爲您正在尋找gmtime功能,而不是gmdate功能。雖然,現在我看到你通過'U'進去了,但我很困惑。

啊,我現在看到,PHP使用gmdate('U')就像Perl 5使用gmtime()一樣。

哎呦,我的記憶中失敗,你需要使用Time::LocalPOSIX::mktime打開的localtimegmtime結果進入新紀元的秒數​​。

#!/usr/bin/perl 

use strict; 
use warnings; 

use POSIX qw/mktime/; 
use Time::Local qw/timegm/; 

print "the time is now ", timegm(localtime()), " or ", mktime(gmtime()), "\n"; 
+0

有區別嗎?你確定?爲什麼我會收到錯誤? – NullVoxPopuli

+0

gmdate:http://www.w3schools.com/php/func_date_gmdate.asp – NullVoxPopuli

+0

哦...這是一個PHP的東西...嗯 – NullVoxPopuli

相關問題