Programming Tips - perl: an easy way to display the time

Date: 2012mar18 Language: perl Q. perl: an easy way to display the time A. If you aren't picky about the exact way it looks, use asctime() like this:
# Required to use asctime(). # But every installation is going to have this. use POSIX; # Obtain the current time. # Or you could use a file's modify time, etc. my $time = time(); # Convert the time to the local timezone with localtime(). # Format it with asctime(). # Then print it. print asctime(localtime($time));
Example output:
Sun Mar 18 06:27:28 2012