Inline::Perl5 now supports passing IO (including deep and dark IO from within XS), so this code works:

use v6; use Slang::Tuxic; use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.use ("Text::CSV_XS"); my @rows; my $csv = $p5.invoke ("Text::CSV_XS", "new") or die "Cannot use CSV: ", $p5.invoke ("Text::CSV_XS", "error_diag +"); $csv.binary (1); $csv.auto_diag (1); my $fh = open "/tmp/hello.csv", :r, chomp => False; my Int $sum = 0; while (my $r = $csv.getline ($fh)) { $sum += +$r; } $sum.say;

To give an example of performance (seconds needed to parse 10000 lines of 5 fields each). Note that Text::CSV::Easy_* only accepts valid CSV and has no options.


Perl 5

Text::CSV::Easy_XS0.019
Text::CSV::Easy_PP0.017
Text::CSV_XS with bind_columns0.033
Text::CSV_XS0.038
Text::CSV_PP0.517
Pegex::CSV1.350

Perl 6

State machine (no options yet)7.027
Inline::Perl5 + Text::CSV_XS13.082
Inline::Perl5 + Text::CSV_XS + getline (IO)13.142
Inline::Perl5 + Text::CSV_PP13.623
Grammar-based (no options yet)13.210
Regex based (no options)39.996
Regex based, all options provided36.075

When I started in october 2014, the Regex based solution took 260 seconds, so improvement in the language itself is made on a daily basis!


Enjoy, Have FUN! H.Merijn

In reply to Re: Perl 5, Python, Rakudo, C/C++, Java, Lua? by Tux
in thread Perl 5, Python, Rakudo, C/C++, Java, Lua? by raiph

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.