Cannot import Perl5 module using Inline::Perl5 into Perl6

前端 未结 2 1102
梦如初夏
梦如初夏 2021-01-18 11:39

I\'m trying to import a Perl5 module I really like https://metacpan.org/pod/Data::Printer using advice from the manual page https://modules.perl6.org/dist/Inline::Perl5:cpan

相关标签:
2条回答
  • 2021-01-18 12:11

    From the github page, https://github.com/niner/Inline-Perl5/issues/128

    > perl6 -Ilib -e 'use Data::Printer:from<Perl5>; my @a = 1, 2, [3, 4, ${a => 1}]; p @a'
    [
        [0] 1,
        [1] 2,
        [2] [
            [0] 3,
            [1] 4,
            [2] {
                a   1
            } (tied to Perl6::Hash)
        ]
    ]
    

    I'm not particularly happy with this though. This is much more complicated than perl5 would have been. One of the main points of using Perl6 over Perl5 is simpler use and syntax. This isn't it. The 'Inline::Perl5' module should be able to be loaded within the script like every other module, not as an option at the command line.

    0 讨论(0)
  • 2021-01-18 12:15

    I think you stumbled on a bug in Inline::Perl5 that seems to happen for the Data::Printer Perl 5 module, so I would suggest you open an issue for it at https://github.com/niner/Inline-Perl5/issues .

    Meanwhile, the syntax has become much simpler. Once you have Inline::Perl5 installed, you only need to add the :from<Perl5> adverb to load a module from Perl 5:

    use Data::Printer:from<Perl5>;
    

    Unfortunately, at this moment that creates the same error that you already described:

    ===SORRY!===
    Unsupported type NativeCall::Types::Pointer<140393737675456> in p5_to_p6
    

    So I don't think there is a solution this that wouldn't require an upgrade of either Inline::Perl5 or Rakudo Perl 6.

    0 讨论(0)
提交回复
热议问题