I've been trying to load in the Perl5 module Data::Printer
into Perl6, but am having a hard time.
I asked this earlier, Cannot import Perl5 module using Inline::Perl5 into Perl6 and did get useful advice from @raiph and Elizabeth, but was advised to do another question
con@con-VirtualBox:~$ perldoc -lm Data::Printer
/usr/local/share/perl/5.26.0/Data/Printer.pm
con@con-VirtualBox:~$ perl6
To exit type 'exit' or '^D'
> use Inline::Perl5;
Nil
> use lib:from<Perl5> '/usr/local/share/perl/5.26.0/Data/';
Nil
> my @a = 1,2,3,4
[1 2 3 4]
> p @a
===SORRY!=== Error while compiling:
Undeclared routine:
p used at line 1
The p
routine should be loaded, and yet it isn't.
alternatively, I try to load, but this produces a bug as well
> use Data::Printer:from<Perl5>
Unsupported type NativeCall::Types::Pointer<94859011731840> in p5_to_p6
in method p5_to_p6_type at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 298
in method unpack_return_values at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 375
in method invoke at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 446
in method import at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 776
in sub EXPORT at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 805
in any statement_control at /usr/lib/nqp/lib/Perl6/Grammar.moarvm line 1
I have no idea how I can usefully load this library into a Perl6 script.
Unsupported type NativeCall::Types::Pointer<94859011731840> in p5_to_p6
This was a bug in Inline::Perl
that was fixed 4 days ago.
You will not get this lastest version if you simply do zef install Inline::Perl5
.
Here is what I did:
# Install a position independent version of perl,
# see https://github.com/niner/Inline-Perl5/
$ perlbrew install perl-5.29.7 --as perl-5.29.7-PIC -Duseshrplib -Dusemultiplicity
$ perlbrew install-cpanm
$ perlbrew use perl-5.29.7-PIC
$ cpanm Data::Printer
$ git clone https://github.com/niner/Inline-Perl5.git
$ cd Inline-Perl5/
# Run: 'zef uninstall Inline::Perl5' first if you already have it installed
$ perl6 configure.pl6
$ make
$ make install # this installs the latest version of Inline::Perl5
$ cd ..
Then I tested this with this script (p.p6):
use Data::Printer:from<Perl5>;
my @a = 1,2,3,4;
p @a;
Running perl6 p.p6
gives now:
[
[0] 1,
[1] 2,
[2] 3,
[3] 4
]
Edit: If you already have installed a position independent perl
binary, the above installation procedure can be simplified:
$ git clone https://github.com/niner/Inline-Perl5.git
$ cd Inline-Perl5/
$ zef uninstall Inline::Perl5
$ zef install . # or alternatively create the `Makefile` as above
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With