jason0 has asked for the wisdom of the Perl Monks concerning the following question:
Most of the time, the scripts I write would benefit from using XS modules. For instance, there is (can be) a significant difference using Text::CSV_XS vs Text::CSV. I wrote a bit of code that will "use" Text::CSV_XS if available otherwise load Text::CSV. Often Text::CSV is installed in a system but not Text::CSV_XS.
Later, I use the following line:my @modules=qw/Text::CSV_XS Text::CSV/; my $module; foreach (@modules) { if ( eval "require $_" ){ $module=$_; $module->import(); last; } }
My question: is there already a way (such as someone else's module) to do this?my $csv=$module->new( { binary => 1, });
Thank you for your time!
--Jason
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: preferred loading of XS modules
by toolic (Bishop) on Nov 25, 2015 at 18:23 UTC | |
by jason0 (Novice) on Nov 25, 2015 at 20:43 UTC | |
|
Re: preferred loading of XS modules
by CountZero (Bishop) on Nov 25, 2015 at 20:35 UTC | |
by choroba (Cardinal) on Nov 25, 2015 at 21:01 UTC | |
by CountZero (Bishop) on Nov 26, 2015 at 06:48 UTC |