perlfan has asked for the wisdom of the Perl Monks concerning the following question:

Asking for a friend...I found Text::CSV_PP, but it seems to come with Text:CSV (XS). TIA

Replies are listed 'Best First'.
Re: Looking for a pure Perl CSV module
by Tux (Canon) on Feb 02, 2022 at 09:01 UTC

    What Fletch said also noted in the docs for Text::CSV:

    CHOOSING BACKEND

    This module respects an environmental variable called PERL_TEXT_CSV when it decides a backend module to use. If this environmental variable is not set, it tries to load Text::CSV_XS, and if Text::CSV_XS is not available, falls back on Text::CSV_PP;

    If you always don't want it to fall back on Text::CSV_PP, set the variable like this (export may be setenv, set and the likes, depending on your environment):

    $ export PERL_TEXT_CSV=Text::CSV_XS % setenv PERL_TEXT_CSV Text::CSV_XS

    If you prefer Text::CSV_XS to Text::CSV_PP (default), then:

     $ export PERL_TEXT_CSV=Text::CSV_XS,Text::CSV_PP

    You may also want to set this variable at the top of your test files, in order not to be bothered with incompatibilities between backends (you need to wrap this in BEGIN, and set before actually use-ing Text::CSV module, as it decides its backend as soon as it's loaded):

    BEGIN { $ENV{PERL_TEXT_CSV} = "Text::CSV_PP"; } use Text::CSV;

    Enjoy, Have FUN! H.Merijn
Re: Looking for a pure Perl CSV module
by Fletch (Bishop) on Feb 02, 2022 at 07:18 UTC

    Not used it but that literally looks to be what you're asking for. That module (Text::CSV) is intended to be a backend agnostic module supporting the same interface as the XS backed Text::CSV_XS provides but falling back to its bundled pure perl implementation if that can't be loaded. It doesn't require the XS module (but will use it if available) so you can just write your code to use it and if the XS version is available you'll get the faster (presumably) implementation transparently.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Looking for a pure Perl CSV module
by LanX (Saint) on Feb 02, 2022 at 11:37 UTC
    I'm confused.

    Are you actually asking how to install Text::CSV_PP without any attempt to also install the XS backend?

    Because both are bundled in the same distribution?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Because both are bundled in the same distribution?

      they're not

Re: Looking for a pure Perl CSV module
by perlfan (Parson) on Feb 02, 2022 at 16:37 UTC
    Thanks for all the replie, everyone gets an upvote!