<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to add time intervals in perl in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837215#M100633</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;My time intervals are in the form hours:mins:secs and are stored in variables.&lt;BR /&gt;&lt;BR /&gt;I want to know how can we add the two variables?&lt;BR /&gt;&lt;BR /&gt;Please answer me .</description>
    <pubDate>Fri, 04 Aug 2006 06:29:09 GMT</pubDate>
    <dc:creator>Pankaj Yadav_1</dc:creator>
    <dc:date>2006-08-04T06:29:09Z</dc:date>
    <item>
      <title>How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837215#M100633</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;My time intervals are in the form hours:mins:secs and are stored in variables.&lt;BR /&gt;&lt;BR /&gt;I want to know how can we add the two variables?&lt;BR /&gt;&lt;BR /&gt;Please answer me .</description>
      <pubDate>Fri, 04 Aug 2006 06:29:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837215#M100633</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-04T06:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837216#M100634</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Perhaps this will show you:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl &lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $t = "1:02:03";&lt;BR /&gt;my ($hr, $min, $sec) = split /:/, $t;&lt;BR /&gt;my $elapsed = ($hr * 3600) + ($min * 60) + $sec;&lt;BR /&gt;print "elapsed time = $elapsed\n";&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 04 Aug 2006 06:40:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837216#M100634</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-04T06:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837217#M100635</link>
      <description>Expanding on James's solution&lt;BR /&gt;NO POINTS please&lt;BR /&gt;&lt;BR /&gt;#!/usr/contrib/bin/perl &lt;BR /&gt;my $t = "1:02:03";&lt;BR /&gt;my $t2 = "10:58:59";&lt;BR /&gt;my ($hr, $min, $sec) = split /:/, $t;&lt;BR /&gt;my ($hr2, $min2, $sec2) = split /:/, $t2;&lt;BR /&gt;my $hr3 = $hr + $hr2;&lt;BR /&gt;my $min3 = $min + $min2;&lt;BR /&gt;my $sec3 = $sec + $sec2;&lt;BR /&gt;my $elapsed = ($hr3 * 3600) + ($min3 * 60) + $sec3;&lt;BR /&gt;my $hr4 = int $elapsed / 3600;&lt;BR /&gt;my $new = $elapsed % 3600 ;&lt;BR /&gt;my $min4 = int $new / 60;&lt;BR /&gt;my $sec4 = $new % 60 ;&lt;BR /&gt;printf "total time = %02d:%02d:%02d\n",$hr4,$min4,$sec4;</description>
      <pubDate>Fri, 04 Aug 2006 07:07:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837217#M100635</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2006-08-04T07:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837218#M100636</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Actually I have two variables like&lt;BR /&gt;&lt;BR /&gt;$a='12:23:44' and $b='1:32:22'&lt;BR /&gt;&lt;BR /&gt;I want to perform &lt;BR /&gt;$c=$a+$b;&lt;BR /&gt;&lt;BR /&gt;The result should also be in the form hours:mins:secs&lt;BR /&gt;&lt;BR /&gt;Please answer me !</description>
      <pubDate>Fri, 04 Aug 2006 07:08:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837218#M100636</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-04T07:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837219#M100637</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm pretty shure you didn't try Peter G. response - of course you have to set $t and $t2 accordingly instead of $a and $b.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 04 Aug 2006 07:21:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837219#M100637</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-08-04T07:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837220#M100638</link>
      <description>Actually my time intervals are stored in an array.&lt;BR /&gt;Please tell me how to take each value from the array and add them and store the final result in a variable in the form hours:mins:sec</description>
      <pubDate>Fri, 04 Aug 2006 07:24:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837220#M100638</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-04T07:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837221#M100639</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;You wrote:&lt;BR /&gt;&lt;BR /&gt;/* begin_quote */&lt;BR /&gt;&lt;BR /&gt;Actually I have two variables like&lt;BR /&gt;&lt;BR /&gt;$a='12:23:44' and $b='1:32:22'&lt;BR /&gt;&lt;BR /&gt;I want to perform &lt;BR /&gt;$c=$a+$b;&lt;BR /&gt;&lt;BR /&gt;The result should also be in the form hours:mins:secs&lt;BR /&gt;&lt;BR /&gt;/* end_quote */&lt;BR /&gt;&lt;BR /&gt;You really have the answer if you think about it.  Convert both $a and $b into seconds as I suggested; add the resultants ($c); and now 'div' and 'mod' as Peter Gordon did in his post!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 04 Aug 2006 07:28:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837221#M100639</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-04T07:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837222#M100640</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;OK, so your variables are contained in an array.  Consider this example:&lt;BR /&gt;&lt;BR /&gt;# perl -le '@a=qw (1:02:03 2:00:00);$t1=$a[0];$t2=$a[1];print "t1=$t1 t2=$t2"'&lt;BR /&gt;&lt;BR /&gt;Remember that Perl (like any good language) treats things zero-relative.  Thus, the first array element is numbered zero, and the second element is element-1.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 04 Aug 2006 07:37:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837222#M100640</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-04T07:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837223#M100641</link>
      <description>I don't know the values neither I know the size of the array since the values present in it is from a SQL query.&lt;BR /&gt;&lt;BR /&gt;I want to add all the values and store the result in another variable.</description>
      <pubDate>Fri, 04 Aug 2006 07:45:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837223#M100641</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-04T07:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837224#M100642</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You wrote, "I don't know the values neither I know the size of the array since the values present in it is from a SQL query. &lt;BR /&gt;I want to add all the values and store the result in another variable."&lt;BR /&gt;&lt;BR /&gt;The size of the array doesn't matter.  I assume that you know the element numbers where the data occurs.&lt;BR /&gt;&lt;BR /&gt;I have shown you in the abstract how to extract elements from an array or list; split them into pieces; and sum them.&lt;BR /&gt;&lt;BR /&gt;Your question keeps changing.  I suggest that you post *exactly* what you have tried to write so that we can attempt to direct you.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 04 Aug 2006 07:51:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837224#M100642</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-04T07:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837225#M100643</link>
      <description>I think I have got the solution.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for all the pain you all took !&lt;BR /&gt;&lt;BR /&gt;If I get further problems I will post here .&lt;BR /&gt;This forum is great since the members are great.&lt;BR /&gt;&lt;BR /&gt;Thanks a lot once again.</description>
      <pubDate>Fri, 04 Aug 2006 07:55:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837225#M100643</guid>
      <dc:creator>Pankaj Yadav_1</dc:creator>
      <dc:date>2006-08-04T07:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to add time intervals in perl</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837226#M100644</link>
      <description>let me make sure I understand. &lt;BR /&gt;&lt;BR /&gt;You don't know which elements of your array contain the values you want to add? But you want to add them and store them as a different variable? &lt;BR /&gt;&lt;BR /&gt;If thats the case you need to figure out what elements they are (print the array) or return the data from your query into a more useful data structure. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Aug 2006 07:56:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-add-time-intervals-in-perl/m-p/3837226#M100644</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-08-04T07:56:57Z</dc:date>
    </item>
  </channel>
</rss>

