エポックに変換して戻る

エポックに変換して戻る

私は次の2つのPerlコマンドラインを正常に使用しました。

perl -e 'use Time::Local; print timelocal(7,51,10,22,3,2014), "\n";'

リターン1398163867

perl -e 'print scalar(localtime(1398163867)), "\n"'

返品Tue Apr 22 10:51:07 2014

私がしたいのは7,51,10,22,3,2014、を1398163867これらの値を含む変数に置き換えることです。どうすればいいですか?

ベストアンサー1

シェル変数を参照する場合:

t=7,51,10,22,3,2014
perl -MTime::Local -le 'print timelocal split ",", shift' -- "$t"

t=1398163867
perl -le 'print scalar localtime shift' -- "$t"

おすすめ記事