Skip to content

Instantly share code, notes, and snippets.

@raiph

raiph/.md Secret

Created January 13, 2020 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raiph/4d54916f13f3094895f950d21b092bba to your computer and use it in GitHub Desktop.
Save raiph/4d54916f13f3094895f950d21b092bba to your computer and use it in GitHub Desktop.
Inline::Perl6 (from SO Import raku's `dir` function into Perl)

See https://stackoverflow.com/questions/59687039/import-rakus-dir-function-into-perl


I know you know Inline::Perl5 for Rakudo (IP5). For other readers, IP5, written by Stefan Seifert, allows Perl modules and code to be used from within Raku code by using Rakudo, the Raku compiler and an embedded libperl.

Stefan also created Inline::Perl6 (on CPAN; on GitHub) for Perl (5). IP6 goes in the reverse direction from IP5 -- it allows Raku modules and code to be used from within Perl.

From IP6's CPAN entry:

This module embeds a MoarVM based Rakudo Perl 6 and allows you to run Perl 6 code, load Perl 6 modules, use methods of Perl 6 objects and much more.

(All from within Perl 5.)

If you try this route, I think you can expect this tech and its doc and support to be at about the same level as you've experienced for IP5. I look forward to helping you out with any issues I see here with the [raku] tag.

Installing IP6 and using Raku code in Perl

Given that you already have Rakudo installed and working, and IP5 installed and at least partially working, I think you now just have to install the IP6 module using whatever Perl installer you use (cpanm?) and install it as per its instructions.

With luck it'll install without incident and then you can just follow IP6's SYNOPSIS on CPAN to get started writing Raku code inside your Perl 5 code.

If you do install it, and get Raku's dir to work, please comment here to say so. Feel free to use exclamation marks and smilies. I'm as excited about seeing use of Raku in Perl as I am use of Perl in Raku.

If you have issues

If you try but fail to install IP6, then please create a gist or similar showing whatever error and system details you can and link to it in a comment on this answer below.

Alternatively, if you manage to install it, but then fail to get Raku's dir function to work, please don't comment here but instead create a new SO showing what you tried that doesn't work, again with copious system details if possible, and tag it with just [raku] for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment