<?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 script from tab deliminated to , deliminated in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382564#M197801</link>
    <description>The problem I am having is that I have some columns that have white space inbetween, and it would split on that...&lt;BR /&gt;00 0 09 29 --&amp;gt; I need this so it would be 5555998,00 0 09 29,TELN NOT&lt;BR /&gt;TELN NOT --&amp;gt; I need this to be one column as well.&lt;BR /&gt;So Basically I would like it to parse the file,  and add commas between columns and then save it to a file.</description>
    <pubDate>Mon, 20 Sep 2004 13:00:09 GMT</pubDate>
    <dc:creator>Ratzie</dc:creator>
    <dc:date>2004-09-20T13:00:09Z</dc:date>
    <item>
      <title>Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382562#M197799</link>
      <description>Right now I am doing alot of prework for a script.&lt;BR /&gt;Save data in word pad, then save a comma deliminated file, dos2ux, then run a perl script on that data.&lt;BR /&gt;I would like to eliminate some steps...&lt;BR /&gt;&lt;BR /&gt;The file comes across as...&lt;BR /&gt;       5555998                         00 0 09 29              TELN NOT&lt;BR /&gt;&lt;BR /&gt;There are lots of spaces inbetween columns, and at front of record.&lt;BR /&gt;&lt;BR /&gt;I want it to look like&lt;BR /&gt;5555998,00 0 09 29,TELN NOT&lt;BR /&gt;&lt;BR /&gt;I want to add this to the befinning of my script that starts like...&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;chomp;  # Will remove the leading , or new line&lt;BR /&gt;my @a = split /,/, $_, -1;&lt;BR /&gt;my $f = /TELN NOT BILL/ ? $ft : /CUST/? $fc : $fo;&lt;BR /&gt;print $f join "," =&amp;gt; $acode.$a[0],$CAPbld, $CAProom, $a[1], $a[2], "\n";&lt;BR /&gt;}&lt;BR /&gt;close $fc;&lt;BR /&gt;close $ft;&lt;BR /&gt;close $fo;&lt;BR /&gt;...</description>
      <pubDate>Mon, 20 Sep 2004 12:05:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382562#M197799</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2004-09-20T12:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382563#M197800</link>
      <description>chomp () will only remove the (optional) *trailing* newline. In fact it is the same as $_ =~ s{$/\Z}{};&lt;BR /&gt;&lt;BR /&gt;any white space in front of that newline is preserved., so if you want to strip leading and trailing whitespace (including newlines),&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;s/\s+$//;&lt;BR /&gt;s/^\s+//;&lt;BR /&gt;&lt;BR /&gt;then just replace the /,/ with the tab&lt;BR /&gt;&lt;BR /&gt;my @a = split m/\t/, $_, -1;&lt;BR /&gt;&lt;BR /&gt;or, if you also want to strip leading and trailing spaces of every field,&lt;BR /&gt;&lt;BR /&gt;my @a = split m/ *\t */, $_, -1;&lt;BR /&gt;note that you cannot use \s before the *, because \s includes \t&lt;BR /&gt;&lt;BR /&gt;the print statement you use, will always add a ',' before the newline. If you don't want that, write&lt;BR /&gt;&lt;BR /&gt;print $f join "," =&amp;gt; $acode.$a[0],$CAPbld, $CAProom, $a[1], "$a[2]\n";&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 20 Sep 2004 12:25:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382563#M197800</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-09-20T12:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382564#M197801</link>
      <description>The problem I am having is that I have some columns that have white space inbetween, and it would split on that...&lt;BR /&gt;00 0 09 29 --&amp;gt; I need this so it would be 5555998,00 0 09 29,TELN NOT&lt;BR /&gt;TELN NOT --&amp;gt; I need this to be one column as well.&lt;BR /&gt;So Basically I would like it to parse the file,  and add commas between columns and then save it to a file.</description>
      <pubDate>Mon, 20 Sep 2004 13:00:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382564#M197801</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2004-09-20T13:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382565#M197802</link>
      <description>Hard to do if the delimiter is not fixed. If it is a tab, and the other whitespace is just spaces, my solution will happily do what you asked it to do.&lt;BR /&gt;&lt;BR /&gt;If there's no fixed delimiters, either tabs o commas, but the file has fixed-width columns, aligned with spaces, use unpack&lt;BR /&gt;&lt;BR /&gt;my @a = unpack "A8 A13 A3 A24 A9 A45 A*", $_;&lt;BR /&gt;&lt;BR /&gt;asuming columns - left to right, are 8, 13, 3, 24, 9, 45, and the rest wide.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 20 Sep 2004 13:13:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382565#M197802</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-09-20T13:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382566#M197803</link>
      <description>Try this script:&lt;BR /&gt;&lt;BR /&gt;for LINE in [filename]; do&lt;BR /&gt;   tr -s [:space:] |tr -s " " ","&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;It will first reduce all occuances of spaces and tabs to a single space, then substitute the space for a comma.&lt;BR /&gt;&lt;BR /&gt;mark&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Sep 2004 14:01:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382566#M197803</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2004-09-20T14:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382567#M197804</link>
      <description>Ok... let's try that again&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for LINE in [filename]; do&lt;BR /&gt; echo $LINE|tr -s [:space:] |tr -s " " "," &amp;gt; [newfilename]&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Sep 2004 14:02:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382567#M197804</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2004-09-20T14:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382568#M197805</link>
      <description>If the columns that might have white space are at the end, then try-&lt;BR /&gt;&lt;BR /&gt;perl -en '@a=split(" +",$_,5); print join(",",@a)'&lt;BR /&gt; &lt;BR /&gt;The ,5 in split will only split up to 5 fields. Then the remaining text field is considered as just one field.&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 20 Sep 2004 15:44:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382568#M197805</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-09-20T15:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382569#M197806</link>
      <description>I am trying to get this to work but I am getting an error...&lt;BR /&gt;&lt;BR /&gt;user@server$ more test.pl&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;chomp;  # Will remove the leading , or new line&lt;BR /&gt;s,^\s+,,; #Remove leading spaces&lt;BR /&gt;my @cols=split(/\s+{2,}/,$_); #Split on two (or more) spaces&lt;BR /&gt;print join (',',@cols)."\n";&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;This is the error...&lt;BR /&gt;&lt;BR /&gt;Nested quantifiers in regex; marked by &amp;lt;-- HERE in m/\s+{ &amp;lt;-- HERE 2,}/ at ./test.pl line 10.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Sep 2004 23:56:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382569#M197806</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2004-09-20T23:56:31Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382570#M197807</link>
      <description>Well, the error message comes really close to identifying the problem:&lt;BR /&gt;&lt;BR /&gt;/\s+{2,}/&lt;BR /&gt;&lt;BR /&gt;Here, the the "+" means: "one or more spaces"&lt;BR /&gt;The "{2,}" means: Two or more of the prior. But 'prior' is this 'one or more' thing. Too tricky!&lt;BR /&gt;&lt;BR /&gt;Fix that by using either: \s{2,}&lt;BR /&gt;or: \s\s+&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;chomp; # Will remove the leading , or new line&lt;BR /&gt;s,^\s+,,; #Remove leading spaces&lt;BR /&gt;my @cols=split(/\s{2,}/,$_); #Split on two (or more) spaces&lt;BR /&gt;print join (',',@cols)."\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Sep 2004 00:13:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382570#M197807</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-09-21T00:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382571#M197808</link>
      <description>And it has still very misleading comments!&lt;BR /&gt;&lt;BR /&gt;re-read my chomp comments&lt;BR /&gt;\s is not a space! it is white space: tabs, new-lines, spaces, \x{85}, \x{2028}, \x{2029}, but not VT&lt;BR /&gt;&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;chomp; # Will remove the optional trailing new line&lt;BR /&gt;s,^\s+,,; #Remove leading spaces&lt;BR /&gt;my @cols=split m/\s{2,}/, $_, -1; # Split on two (or more) white space characters&lt;BR /&gt;print join (',', @cols), "\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Tue, 21 Sep 2004 01:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382571#M197808</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2004-09-21T01:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script from tab deliminated to , deliminated</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382572#M197809</link>
      <description>Excellent I have it working thank you to all who have helped out.&lt;BR /&gt;Now on to another little glich regarding the same script. But I will post new on this subject.</description>
      <pubDate>Tue, 21 Sep 2004 10:28:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-from-tab-deliminated-to-deliminated/m-p/3382572#M197809</guid>
      <dc:creator>Ratzie</dc:creator>
      <dc:date>2004-09-21T10:28:23Z</dc:date>
    </item>
  </channel>
</rss>

