<?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 split function question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655012#M658519</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; does it sound logical ??&lt;BR /&gt;&lt;BR /&gt;If this works for your data then, OK.&lt;BR /&gt;&lt;BR /&gt;You should use (as Merijn pointed out in an earlier thread of yours) the 'Text::CSV' module to parse CSV data.&lt;BR /&gt;&lt;BR /&gt;Why are you slurping the whole file rather than reading a one line at a time?&lt;BR /&gt;&lt;BR /&gt;You should be using 'use strict'.  This will save you from making stupid mistakes and wasting hours chasing them down.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Wed, 30 Jun 2010 11:31:56 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2010-06-30T11:31:56Z</dc:date>
    <item>
      <title>Perl split function question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655010#M658517</link>
      <description>I need to get array values to the variable from a .csv data file. it is OK the following code to test but every line has a newline at the line end,also neeed to get rid of this somehow; as shown in ARRAY 68 there is line end (newline) character, and need to split also this array ,tried as you can see in commented out below, but I could not as far :&lt;BR /&gt;CODE:&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;$FILE = 'pnm_om.06_14_2010.0030.ISBLTUGS01D.OT.CSV';&lt;BR /&gt;&lt;BR /&gt;open(FILE) or die ("Could not open file.");&lt;BR /&gt;{ local $/; $content = &lt;FILE&gt; }&lt;BR /&gt;@column = split(/[\s]*[,][\s]*/,$content);&lt;BR /&gt;#@column = split(/\n/,$column);&lt;BR /&gt;for ( $I = 0; $I &amp;lt;= 80; $I++ ) {&lt;BR /&gt; print "ARRAY $I : $column[$I]\n";&lt;BR /&gt; }&lt;BR /&gt;RESULT:&lt;BR /&gt;ARRAY 0 : Date&lt;BR /&gt;ARRAY 1 : Time&lt;BR /&gt;ARRAY 2 : Switch Name&lt;BR /&gt;ARRAY 3 : Group Name&lt;BR /&gt;.....&lt;BR /&gt;ARRAY 65 : Reg31 Name&lt;BR /&gt;ARRAY 66 : Reg31 Value&lt;BR /&gt;ARRAY 67 : Reg32 Name&lt;BR /&gt;ARRAY 68 : Reg32 Value&lt;BR /&gt;06-14-2010&lt;BR /&gt;ARRAY 69 : 00:30:08&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Wed, 30 Jun 2010 11:14:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655010#M658517</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-30T11:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Perl split function question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655011#M658518</link>
      <description>The solution is:&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;$FILE = 'pnm_om.06_14_2010.0030.ISBLTUGS01D.OT.CSV';&lt;BR /&gt;&lt;BR /&gt;open(FILE) or die ("Could not open file.");&lt;BR /&gt;{ local $/; $content = &lt;FILE&gt; }&lt;BR /&gt;@column = split(/[\s]*[,\n][\s]*/,$content);&lt;BR /&gt;#@column = split(/\n/,$column);&lt;BR /&gt;for ( $I = 0; $I &amp;lt;= 80; $I++ ) {&lt;BR /&gt;print "ARRAY $I : $column[$I]\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;does it sound logical ??&lt;BR /&gt;Thanks in advance.&lt;/FILE&gt;</description>
      <pubDate>Wed, 30 Jun 2010 11:20:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655011#M658518</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-30T11:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Perl split function question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655012#M658519</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; does it sound logical ??&lt;BR /&gt;&lt;BR /&gt;If this works for your data then, OK.&lt;BR /&gt;&lt;BR /&gt;You should use (as Merijn pointed out in an earlier thread of yours) the 'Text::CSV' module to parse CSV data.&lt;BR /&gt;&lt;BR /&gt;Why are you slurping the whole file rather than reading a one line at a time?&lt;BR /&gt;&lt;BR /&gt;You should be using 'use strict'.  This will save you from making stupid mistakes and wasting hours chasing them down.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 30 Jun 2010 11:31:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655012#M658519</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-06-30T11:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Perl split function question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655013#M658520</link>
      <description>&amp;gt;You should use (as Merijn pointed out in an earlier thread of yours) the 'Text::CSV' module to parse CSV data.&lt;BR /&gt;&lt;BR /&gt;Because its dependency is some C stuff like cc that is not available in customer environment, &lt;BR /&gt;&lt;BR /&gt;&amp;gt;Why are you slurping the whole file rather than reading a one line at a time?&lt;BR /&gt;&lt;BR /&gt;Speed!&lt;BR /&gt;I already wrote a code with test purpose Text::CSV (older version of Merijn wrote) ,and tried, it was so slow to process my input file .</description>
      <pubDate>Wed, 30 Jun 2010 11:58:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655013#M658520</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2010-06-30T11:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Perl split function question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655014#M658521</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;You could do things more Perl-ishly and rigorously like:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $file = '/tmp/mycsv';&lt;BR /&gt;my ( $fh, $content, @column );&lt;BR /&gt;open( $fh, '&amp;lt;', $file ) or die("Could not open '$file'");&lt;BR /&gt;{&lt;BR /&gt;    local $/;&lt;BR /&gt;    $content = &amp;lt;$fh&amp;gt;;&lt;BR /&gt;}&lt;BR /&gt;@column = split( /\s*[,\n]\s*/, $content );&lt;BR /&gt;my $j = 0;&lt;BR /&gt;for my $i (@column) {&lt;BR /&gt;    print "ARRAY", $j++, " : ", "$i\n";&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 30 Jun 2010 12:15:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655014#M658521</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-06-30T12:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Perl split function question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655015#M658522</link>
      <description>The Text::xSV module does not have C-language dependencies; it is pure Perl.  I would strongly recommend you look into using this module for all of your CSV file parsing needs.  It's available on CPAN as well as PPM.&lt;BR /&gt;&lt;BR /&gt;--Geoff</description>
      <pubDate>Thu, 12 Aug 2010 14:55:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-split-function-question/m-p/4655015#M658522</guid>
      <dc:creator>Geoff Gariepy</dc:creator>
      <dc:date>2010-08-12T14:55:33Z</dc:date>
    </item>
  </channel>
</rss>

