On Wed, 13 Jan 2016 16:31:15 -0800, ToddAndMargo
<toddandma...@zoho.com> wrote:

> On 01/13/2016 12:51 PM, David H. Adler wrote:
> > On Wed, Jan 13, 2016 at 12:50:19PM -0800, ToddAndMargo wrote:  
> >> Hi All,
> >>
> >> I have written myself several Perl 5 modules (.pm).
> >> Is there a way to call them from Perl6?  Or should I
> >> must I rewrite them?  
> >
> > https://doc.perl6.org/language/faq#Can_I_use_Perl_5_modules_from_Perl_6%3F
> >
> > dha
> >  
> 
> Hi David,
> 
> Not to be dense, but will inline::Perl5 also work with
> all those CPAN modules?
> 
> Also, does inline::Perl5 get installed natively when I
> install Perl6, or do I need to install it afterwards?

You need to install it afterwards:

$ panda install Inline::Perl5

Most (if not all) perl5 modules will work, but not out of the box.
If you e.g. have an XS module (compiled C code), you might need to do
more changes.

Here's an example of ported DBI code:
--8<---
#!perl6

use v6;
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 Int $sum = 0;
for lines() {
    $csv.parse($_);
    $sum += $csv.fields.elems;
    }
$sum.say;
-->8---

> Many thanks,
> -T
> 


-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.23   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Attachment: pgpaYdxq6ggjB.pgp
Description: OpenPGP digital signature

Reply via email to