15

Is the a way to use Perl 5 modules from CPAN from Rakudo Perl 6?

For example, how can I use the venerable Perl 5 module, CGI, which hasn't been ported yet, in Perl 6.

Update:

And what this funky code from some early Perl 6 module:

use CGI:from<perl5>;

Is the :from<perl5> directive used to evoke some kind of a Perl 5 compatibility layer? Can't seem to find any documentation about it.

3
  • 1
    I understand CGI is just a example, but for modern web development you could look Dancer for Perl6 Commented Feb 7, 2012 at 13:10
  • possible duplicate of Are perl5 libraries are importable in perl6? Commented Aug 26, 2013 at 12:18
  • 1
    Like @w.k., I understand CGI is just an example, but, like them, I also want to mention a native Raku option for web dev, though in my case it's from the perspective of late 2019: Cro. Commented Nov 30, 2019 at 21:08

2 Answers 2

10

Use Inline::Perl5.


The following example shows how to use the CPAN hosted Perl 5 module Text::Unidecode ("the Unicode transliteration of last resort") in Raku.

First, install Inline::Perl5 if you don't already have it installed:

zef install Inline::Perl5

Now install the CPAN module if you don't already have it installed:

perl -MCPAN -e "install Text::Unidecode"

You can now use the installed Perl module by writing a use statement with an appended :from<Perl5> (with an uppercase P, not :from<perl5>) :

use Text::Unidecode:from<Perl5>;
say Text::Unidecode::unidecode 'Solidarność';

displays:

Solidarnosc

See also other SO posts about Inline::Perl5.

Sign up to request clarification or add additional context in comments.

2 Comments

@raiph I added your comment to the answer, feel free to edit it further
When I try to install Inline::Perl5 it says it can't find resources\libraries\p5helper.dll
0

There is blizkost project that aims to use of perl5 code from Rakudo/Parrot. However it is AFAIK in quite early stage of development and probably not usable for real code.

3 Comments

The last commit was more than a year ago.
@BradGilbert - yeah, thats why I put the warning there. However this is only project I know of that aims at using perl5 in parrot.
@bvr Parrot for Perl6 is also kind of dead. Rakudo FTF! (for the future)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.