{"id":7661,"date":"2015-01-12T21:25:38","date_gmt":"2015-01-12T21:25:38","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=7661"},"modified":"2015-01-12T21:33:37","modified_gmt":"2015-01-12T21:33:37","slug":"perl-the-time-vector","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/perl-the-time-vector\/","title":{"rendered":"Perl:  the time vector"},"content":{"rendered":"<h1>The tutor continues about Perl&#8217;s handling of time.<\/h1>\n<p>&nbsp;<br \/>\nIn <a href=\"?p=7644\">yesterday&#8217;s post<\/a> I began about Perl&#8217;s time utilities.<\/p>\n<p>Besides <span style=\"font-family:monospace\">localtime<\/span>, there is simply <span style=\"font-family:monospace\">time<\/span>.  It returns the number of seconds since January 1, 1970 on the Windows system I use, as well as on most others <a href=\"http:\/\/www.tutorialspoint.com\/perl\/perl_time.htm\">(tutorialspoint.com)<\/a>.<\/p>\n<p>These few lines of code<br \/>\n<span style=\"font-family:monospace;color:brown\"><br \/>\n#!\/usr\/bin\/perl<br \/>\n$tim0=time;<br \/>\nprint &#8220;The time is $tim0\\n&#8221;;<\/span><br \/>\nwill hopefully give output like<\/p>\n<p><span style=\"font-family:monospace\">The time is 1421093858<\/span><\/p>\n<p>There is even more to Perl&#8217;s handling of time than we&#8217;ve seen so far.  Perl offers a veritable vector of time information to those desiring it.  Consider the following little program:<br \/>\n<span style=\"font-family:monospace;color:brown\"><br \/>\n#!\/usr\/bin\/perl<br \/>\n@timarray=localtime;<br \/>\n$length=@timarray;<span style=\"color:blue\"> #gives length of the array<\/span><br \/>\nfor($i=0; $i<$length; $i++){<br \/>\nprint &#8220;Element $i of Perl&#8217;s time array is $timarray[$i]\\n&#8221;;<br \/>\n}<\/p>\n<p>Running the lines above, you may be greeted with output like this:<br \/>\n<span style=\"font-family:monospace\"><br \/>\nElement 0 of Perl&#8217;s time array is 2 <span style=\"color:green\">\/\/seconds<\/span><br \/>\nElement 1 of Perl&#8217;s time array is 44 <span style=\"color:green\">\/\/minutes<\/span><br \/>\nElement 2 of Perl&#8217;s time array is 12 <span style=\"color:green\">\/\/hours<\/span><br \/>\nElement 3 of Perl&#8217;s time array is 12 <span style=\"color:green\">\/\/the day this month<\/span><br \/>\nElement 4 of Perl&#8217;s time array is 0 <span style=\"color:green\">\/\/the month: Jan=0<\/span><br \/>\nElement 5 of Perl&#8217;s time array is 115 <span style=\"color:green\">\/\/the year: 1900=0<\/span><br \/>\nElement 6 of Perl&#8217;s time array is 1 <span style=\"color:green\">\/\/day of the week: Sun=0<\/span><br \/>\nElement 7 of Perl&#8217;s time array is 11 <span style=\"color:green\">\/\/the day this year:Jan 1=0<\/span><br \/>\nElement 8 of Perl&#8217;s time array is 0 <span style=\"color:green\">\/\/daylight savings: no=0, yes=1<\/span><\/span><\/p>\n<p>For now, this wraps up my coverage of Perl time functions.  HIH:)<\/p>\n<p>Source:  McGrath, Mike.  <em>Perl in easy steps<\/em>.  Southam:  Computer Step, 2004.<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor continues about Perl&#8217;s handling of time. &nbsp; In yesterday&#8217;s post I began about Perl&#8217;s time utilities. Besides localtime, there is simply time. It returns the number of seconds since January 1, 1970 on the Windows system I use, &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/perl-the-time-vector\/\"> <span class=\"screen-reader-text\">Perl:  the time vector<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[173,426,425,424],"class_list":["post-7661","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-perl-programming","tag-perl-time","tag-time-array","tag-time-vector"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/7661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=7661"}],"version-history":[{"count":29,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/7661\/revisions"}],"predecessor-version":[{"id":7690,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/7661\/revisions\/7690"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=7661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=7661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=7661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}