Sunday, July 20, 2008

Current time with perl

Q. How do I know the current time with perl?

A. The 'time' variable holds the current time.
print time; would print the current time but not in a language that you would understand.
To get the current time as something like Jan 20, 2008 12:30:00 use the time variable wrapped in the localtime function. So, try

perl -e 'print localtime(time);' on the UNIX command prompt.

No comments: