<?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 Re: Perl; in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647140#M676841</link>
    <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; still prints the result one line at a time wheras I want the total in loop;&lt;BR /&gt;&lt;BR /&gt;Look at this test-case:&lt;BR /&gt;&lt;BR /&gt;# cat ./mytest&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( $calc, @values );&lt;BR /&gt;while (&lt;DATA&gt;) {&lt;BR /&gt;    @values = split;&lt;BR /&gt;    if ($values[1] =~ m{23:}) {&lt;BR /&gt;        $calc += $values[4];&lt;BR /&gt;        print "Time: $values[1] ROUTE_CCLI: VERSOSIP.2W.900.900 $calc\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;print "LAST: $values[1] ROUTE_CCLI: VERSOSIP.2W.900.900 $calc\n";&lt;BR /&gt;1;&lt;BR /&gt;__DATA__&lt;BR /&gt;Time: 23:00 ROUTE_CLLI: VERSOSIP.2W.900.900 130&lt;BR /&gt;Time: 23:10 ROUTE_CLLI: VERSOSIP.2W.900.900 100&lt;BR /&gt;Time: 23:20 ROUTE_CLLI: VERSOSIP.2W.900.900 100&lt;BR /&gt;Time: 23:30 ROUTE_CLLI: VERSOSIP.2W.900.900 127&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...now run as './mytest' and you will see:&lt;BR /&gt;&lt;BR /&gt;Time: 23:00 ROUTE_CCLI: VERSOSIP.2W.900.900 130&lt;BR /&gt;Time: 23:10 ROUTE_CCLI: VERSOSIP.2W.900.900 230&lt;BR /&gt;Time: 23:20 ROUTE_CCLI: VERSOSIP.2W.900.900 330&lt;BR /&gt;Time: 23:30 ROUTE_CCLI: VERSOSIP.2W.900.900 457&lt;BR /&gt;LAST: 23:30 ROUTE_CCLI: VERSOSIP.2W.900.900 457&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/DATA&gt;</description>
    <pubDate>Mon, 14 Jun 2010 12:26:40 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2010-06-14T12:26:40Z</dc:date>
    <item>
      <title>Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647134#M676835</link>
      <description>Hi the following Perl snippet use Text::CSV; and according to time stamps add some columns vaule.&lt;BR /&gt;&lt;BR /&gt;    while (&lt;CSV&gt;) {&lt;BR /&gt;        next if ($. == 1);&lt;BR /&gt;        if ($csv-&amp;gt;parse($_)) {&lt;BR /&gt;           my @columns = $csv-&amp;gt;fields();&lt;BR /&gt;        #Get HR MIN SEC by splitting the time_stamp in column 1&lt;BR /&gt;         my $col = substr ( $columns[1],0,8 );&lt;BR /&gt;         my @col = split (/:/,$col);&lt;BR /&gt;         my $hour = $col[0];&lt;BR /&gt;         my $minute = $col[1];&lt;BR /&gt;         my $secs = $col[2];&lt;BR /&gt;&lt;BR /&gt;if (( $hour == 23 ) &amp;amp;&amp;amp; ( $columns[4] eq 'VERSOSIP.2W.900.900' )) {&lt;BR /&gt;         my $calcs += $columns[6];&lt;BR /&gt;         print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$columns[6]\n";&lt;BR /&gt;           }&lt;BR /&gt;        } else {&lt;BR /&gt;            my $err = $csv-&amp;gt;error_input;&lt;BR /&gt;            print "Failed to parse line: $err";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;it prints out the rows like this:&lt;BR /&gt;Time: 23:00     ROUTE_CLLI: VERSOSIP.2W.900.900 130&lt;BR /&gt;Time: 23:30     ROUTE_CLLI: VERSOSIP.2W.900.900 127&lt;BR /&gt;&lt;BR /&gt;But I wanted it have results added like this;&lt;BR /&gt;Time: 23:30     ROUTE_CLLI: VERSOSIP.2W.900.900 257&lt;BR /&gt;&lt;BR /&gt;How can I achieve this OR which function you think is able to do it ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CSV&gt;</description>
      <pubDate>Mon, 14 Jun 2010 10:39:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647134#M676835</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-14T10:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647135#M676836</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;You are printing every line of input rather than a line representing a summation.&lt;BR /&gt;&lt;BR /&gt;Instead of:&lt;BR /&gt;&lt;BR /&gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$columns[6]\n";&lt;BR /&gt;&lt;BR /&gt;...you want something like:&lt;BR /&gt;&lt;BR /&gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$calc\n";&lt;BR /&gt;&lt;BR /&gt;..and you want this to occur after the read loop (while...) has ended.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 14 Jun 2010 11:18:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647135#M676836</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-06-14T11:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647136#M676837</link>
      <description>Hi James,&lt;BR /&gt;&amp;gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$calc\n";&lt;BR /&gt;&lt;BR /&gt;..and you want this to occur after the read loop (while...) has ended.&lt;BR /&gt;&lt;BR /&gt;Yes, but my method only result the what they read per line.Not summary.&lt;BR /&gt;&lt;BR /&gt;it can either be inside while loop OR loop has ended.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;Hakki&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jun 2010 11:38:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647136#M676837</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-14T11:38:50Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647137#M676838</link>
      <description>Hi (again) Hakki:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Yes, but my method only result the what they read per line.Not summary. it can either be inside while loop OR loop has ended.&lt;BR /&gt;&lt;BR /&gt;So I presume you want "running totals".  Then change:&lt;BR /&gt;&lt;BR /&gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$columns[6]\n"&lt;BR /&gt;&lt;BR /&gt;...to:&lt;BR /&gt;&lt;BR /&gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$calc[6]\n"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jun 2010 11:47:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647137#M676838</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-06-14T11:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647138#M676839</link>
      <description>Hi (again) Hakki:&lt;BR /&gt;&lt;BR /&gt;Oops, I hit submit too soon.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Yes, but my method only result the what they read per line.Not summary. it can either be inside while loop OR loop has ended.&lt;BR /&gt;&lt;BR /&gt;So I presume you want "running totals".  Then change:&lt;BR /&gt;&lt;BR /&gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$columns[6]\n"&lt;BR /&gt;&lt;BR /&gt;...to:&lt;BR /&gt;&lt;BR /&gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$calc\n"&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jun 2010 11:48:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647138#M676839</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-06-14T11:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647139#M676840</link>
      <description>Hi James,&lt;BR /&gt;&lt;BR /&gt;print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$calc\n" ;&lt;BR /&gt;&lt;BR /&gt;still prints the result one line at a time wheras I want the total in loop;&lt;BR /&gt;it prints below:&lt;BR /&gt;&lt;BR /&gt;Time: 23:00     ROUTE_CLLI: VERSOSIP.2W.900.900 130&lt;BR /&gt;23 00&lt;BR /&gt;Time: 23:30     ROUTE_CLLI: VERSOSIP.2W.900.900 127&lt;BR /&gt;23 30&lt;BR /&gt;&lt;BR /&gt;I want:&lt;BR /&gt;Time: 23:30     ROUTE_CLLI: VERSOSIP.2W.900.900 257&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Jun 2010 12:00:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647139#M676840</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-14T12:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647140#M676841</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; still prints the result one line at a time wheras I want the total in loop;&lt;BR /&gt;&lt;BR /&gt;Look at this test-case:&lt;BR /&gt;&lt;BR /&gt;# cat ./mytest&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( $calc, @values );&lt;BR /&gt;while (&lt;DATA&gt;) {&lt;BR /&gt;    @values = split;&lt;BR /&gt;    if ($values[1] =~ m{23:}) {&lt;BR /&gt;        $calc += $values[4];&lt;BR /&gt;        print "Time: $values[1] ROUTE_CCLI: VERSOSIP.2W.900.900 $calc\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;print "LAST: $values[1] ROUTE_CCLI: VERSOSIP.2W.900.900 $calc\n";&lt;BR /&gt;1;&lt;BR /&gt;__DATA__&lt;BR /&gt;Time: 23:00 ROUTE_CLLI: VERSOSIP.2W.900.900 130&lt;BR /&gt;Time: 23:10 ROUTE_CLLI: VERSOSIP.2W.900.900 100&lt;BR /&gt;Time: 23:20 ROUTE_CLLI: VERSOSIP.2W.900.900 100&lt;BR /&gt;Time: 23:30 ROUTE_CLLI: VERSOSIP.2W.900.900 127&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...now run as './mytest' and you will see:&lt;BR /&gt;&lt;BR /&gt;Time: 23:00 ROUTE_CCLI: VERSOSIP.2W.900.900 130&lt;BR /&gt;Time: 23:10 ROUTE_CCLI: VERSOSIP.2W.900.900 230&lt;BR /&gt;Time: 23:20 ROUTE_CCLI: VERSOSIP.2W.900.900 330&lt;BR /&gt;Time: 23:30 ROUTE_CCLI: VERSOSIP.2W.900.900 457&lt;BR /&gt;LAST: 23:30 ROUTE_CCLI: VERSOSIP.2W.900.900 457&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/DATA&gt;</description>
      <pubDate>Mon, 14 Jun 2010 12:26:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647140#M676841</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-06-14T12:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647141#M676842</link>
      <description>Hi James,&lt;BR /&gt;&lt;BR /&gt;Your code is working great. Probably my module in use needs another type of definition OR I did a logical mistake something else.&lt;BR /&gt;&lt;BR /&gt;Regards!</description>
      <pubDate>Mon, 14 Jun 2010 13:04:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647141#M676842</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-14T13:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Perl;</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647142#M676843</link>
      <description>Solution is to declare a global outside the loop before, working code is:&lt;BR /&gt;&lt;BR /&gt;# cat test3&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;    use strict;&lt;BR /&gt;    use warnings;&lt;BR /&gt;    use Text::CSV;&lt;BR /&gt;   my ( $calc );&lt;BR /&gt;    my $file = 'pnm_om.05_04_2010.0030.ISBLTUGS01D.OT.CSV';&lt;BR /&gt;&lt;BR /&gt;    my $csv = Text::CSV-&amp;gt;new();&lt;BR /&gt;&lt;BR /&gt;    open (CSV, "&amp;lt;", $file) or die $!;&lt;BR /&gt;&lt;BR /&gt;    while (&lt;CSV&gt;) {&lt;BR /&gt;        next if ($. == 1);&lt;BR /&gt;        if ($csv-&amp;gt;parse($_)) {&lt;BR /&gt;        my @columns = $csv-&amp;gt;fields();&lt;BR /&gt;        #Get HR MIN SEC by splitting the time_stamp in column 1&lt;BR /&gt;         my $col = substr ( $columns[1],0,8 );&lt;BR /&gt;         my @col = split (/:/,$col);&lt;BR /&gt;         my $hour = $col[0];&lt;BR /&gt;         my $minute = $col[1];&lt;BR /&gt;         my $secs = $col[2];&lt;BR /&gt;&lt;BR /&gt;if (( $hour == 20 ) &amp;amp;&amp;amp; ( $columns[4] eq 'VERSOSIP.2W.1500.1500' )) {&lt;BR /&gt;         $calc += $columns[6];&lt;BR /&gt;         print "Time: $columns[1]\tROUTE_CLLI: $columns[4]\t$calc\n";&lt;BR /&gt;         print "$hour $minute\n";&lt;BR /&gt;           }&lt;BR /&gt;        } else {&lt;BR /&gt;            my $err = $csv-&amp;gt;error_input;&lt;BR /&gt;            print "Failed to parse line: $err";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;    close CSV;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks again James!&lt;/CSV&gt;</description>
      <pubDate>Mon, 14 Jun 2010 13:41:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl/m-p/4647142#M676843</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-14T13:41:19Z</dc:date>
    </item>
  </channel>
</rss>

