Guru's, I'm having difficulty forcing the integers for all my fields that I'm out putting. I defined the type but I still have fields out putting as character fields.
#!/usr/bin/perl -w use strict; use warnings; use Text::CSV_XS; my ($reporttype,$sorter2,$price,$account,$amount,$check_no,$date_time, +$prod_no,$rundate); $reporttype = 0; $sorter2 = 0; $account = 0; $amount = 0; $check_no = 0; my $procdate = sprintf "%02d%02d%02d%02d%02d%02d", (localtime)[4]+1, ( +localtime)[3], substr((localtime)[5]+1900,2,2),(localtime)[2], (local +time)[1], (localtime)[0]; open SOURCE, "< C:/B01.PRN" or die "can't open file $!"; open CSVFILE, ">> C:/test_" . $procdate . ".csv"; my $csv = Text::CSV_XS->new({eol => "\n"}); $csv->types ([Text::CSV_XS::IV (), Text::CSV_XS::IV (), Text::CSV_XS::IV (), Text::CSV_XS::IV ()]); while(my $source = <SOURCE>) { if (substr($source,7,4) =~ /\d\d\d\d/ && $reporttype == 1 && $sort +er2 == 1){ $prod_no = substr($source,88,8); $account = int(substr($source,22,10)); $price = substr($source,7,9); $check_no = substr($source,48,16); $amount = substr($source,32,16); #$amount =~ s/,//; #$amount = $amount; $csv->combine($prod_no, $account, $price, $check_no,$amount); print $csv->string; printf CSVFILE $csv->string; }; }; close SOURCE;

In reply to Text::CSV_XS; Type Method by drodinthe559

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.