1 / 6

Dates and Times in Perl

Dates and Times in Perl. CSCI333 – Systems Programming Friday, November 18, 2011. time. The time function returns the number of seconds elapsed since the system’s epoch (ex., January 1, 1970): $elapsed=time; Example: t1.txt. localtime.

keren
Download Presentation

Dates and Times in Perl

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dates and Times in Perl CSCI333 – Systems Programming Friday, November 18, 2011

  2. time • The time function returns the number of seconds elapsed since the system’s epoch (ex., January 1, 1970): $elapsed=time; Example: t1.txt

  3. localtime • The localtime function returns a list of seven values: ($sec,$min,$hr,$mday,$mon,$yr,$wday,$yday,$isdst) =localtime(time); 0<=$sec<=59, 0<=$min<=59, 0<=$hr<=23, 1<=$mday<=31 0<=$mon<=11, $yr has 1900 subtracted from it 0<=$wday<=6, 1<=$yday<=366 $isdst=1 means Daylight Savings Time in effect Example: t2.txt

  4. times • The times function returns a list of four values (user and system times for the current process and its children): ($user, $system, $cuser, $csystem)= times; Example: t3.txt

  5. Time elapsed • To compute the time elapsed for a particular Perl code segment, you can use the times function: $beginning = (times)[0]; { do some stuff } $end = (times)[0]; $time_elapsed = $end - $beginning Example: t3.txt

  6. Time::Piece module • The Time::Piece Perl module replaces the standard time functions in a backwards compatible manner. • http://search.cpan.org/~msergeant/Time-Piece/Piece.pm Example: t4.txt

More Related