How can I use Perl 5 modules from Perl 6? - perl

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.

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.

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.

Related

Does Devel::Peek exist as a standalone Perl module?

I have a clean install of perl 5.26.3, and I am trying to install Dancer2.
Dancer2 depends on App::Cmd::Setup, which depends on Getopt::Long::Descriptive, which depends on Params::Validate, which depends on Devel::Peek.
Looking at Devel::Peek on MetaCPAN, it is part of the perl 5.30.2 distribution, and I can not find the Devel::Peek package by itself. The "Jump to version" list on the Devel::Peek page lists previous version of perl, not of Devel::Peek.
Installing Dancer2 on perl 5.26.3 apparently has a hard, transitive dependency of installing perl 5.30.2, but I do not have the authority -- nor any desire -- to update the perl installation.
Is there a version of Devel::Peek available by itself?
Thank you.
Edit
It looks like I have a broken perl installation. I have no Data/Peek.pm anywhere on the filesystem. When I try to use Devel::Peek, I am told Can't locate Devel/Peek.pm in #INC.
I'll install from scratch and start over.
You should be able to fix it with the installation of
yum perl-Devel-Peek
For alpine, be sure to do apk add perl-dev to add additional modules needed to build some packages.
No. It's only available as part of Perl. It's has been part of Perl since 5.6 in 2000.
As such, if you don't have Devel::Peek, you have a broken or partial Perl installation. But this is actually quite common, since many package managers break down Perl into different packages. For example, RHEL split off Devel::Peek into the perl-Devel-Peek package. So if we're talking about a Perl managed by a package manager, check the package manager for the missing bits.

Isn't List::Util part of Standard Perl Distribution?

On a certain system, I am running a perl script and it's failing by saying
Can't locate List/Util.pm in #INC (#INC contains: <Some-Path>/ActiveState/perl/lib <Some-Path>/ActiveState/perl/site/lib .) at <Some-Other-Path>\searchCobolPgms.ps line 7.
Now the strange part is that before deploying the code into the failing system, I ran it on my laptop and it just ran fine. The difference in both the system is, in my laptop I am using Cygwin and perl is bundled with it and the said failing system has ActiveState perl.
<Some-Path>perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 635 provided by ActiveState Corp. http://www.ActiveState.com
Built 15:34:21 Feb 4 2003
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
I then searched for Util under the lib of cygwin and it was present under i686-cygwin
c:\cygwin\lib\perl5\5.10>find . -name Util.pm
./CGI/Util.pm
./i686-cygwin/Hash/Util.pm
./i686-cygwin/List/Util.pm
./i686-cygwin/Scalar/Util.pm
So now I am confused. Isn;t List::Util part of the standard perl distribution?
The Reason for my confusion
List/Util.pm is present under i686-cygwin
ActiveSync Installation was not having List/Util.pm
List::Util was only added to core in 5.7 (a development version) and the first stable release of perl containing List::Util was 5.8.0. So, while it is in the perl 5.10 distro you have installed under cygwin, the perl 5.6.1 ActiveState executable you called does not have it. You should update the ActiveState perl to at least 5.8.0, and then it will have the module you need.
Here is a link to find all versions of perl that contain a core module: http://perlpunks.de/corelist/version?module=List%3A%3AUtil
When I check corelist I get:
corelist List::Util
List::Util was first released with perl v5.7.3
Your perl version seems to be 5.6.1, in which case List::Util would not be part of the core installation.
Judging by the path c:\cygwin\lib\perl5\5.10, it seems your cygwin version is at least 5.10, but as you will note, the cygwin path is not in the #INC of your other perl version. They are most likely separate installations, and therefore they do not share libraries.
Update your ActiveState perl, and all should be well.

How do I install a Perl module that's on Sourceforge and not CPAN using ActiveState?

Trying to install Ptkdb on Windows 7 with Perl 5.12.2 (ActiveState) — how do I do this?
ptkdb is available on CPAN. It's also available for Perl 5.12 in the bribes repository:
ppm install http://www.bribes.org/perl/ppm/Devel-ptkdb.ppd
For pure Perl modules, all you need to do is run the Makefile.PL that comes with the module. If the module is a mix of Perl and C, you will need to get a C/C++ compiler for Windows that works with your distribution of Perl. I would recommend asking around for a Windows binary first if it's a mixed module.

What are the differences between Vanilla Perl and Strawberry Perl?

Strawberry Perl is "Open Source Perl for Windows that is exactly the same
as Perl everywhere else". Vanilla Perl "provides a Perl distribution that is as close to the Perl core as possible." Strawberry Perl is built on Vanilla Perl.
Both distributions come with a C compiler so that perl modules from CPAN that use XS can be built.
What are the differences between Strawberry Perl and Vanilla Perl?
Just read the explanation on the Vanilla Perl homepage
Vanilla Perl Series
The Vanilla Perl series provides a
Perl distribution that is as close to
the Perl core as possible. If
necessary, it may include
win32-specific fixes.
Vanilla Perl is experimental and is
not intended for production purposes.
It is targeted to master-level Win32
Perl developers and those who wish to
experiment with building their own
custom Win32 Perl distributions.
Vanilla Perl releases are numbered
only as sequential 'builds' and will
not follow any alpha/beta/release
plan. This means incremental builds
may be less stable than previous
builds as new release configurations
are tested.
And
Strawberry Perl Series
The purpose of the Strawberry Perl
series is to provide a more practical
Win32 Perl release for experienced
Perl developers to experiment and test
the installation of various CPAN
modules under Win32 conditions, and to
provide a useful platform for
experienced Perl developers to start
doing real work.
In addition to the modules in Vanilla
Perl, Strawberry will also include the
entire dependency tree for
Bundle::CPAN, as well as an additional
set of upgraded versions of dual
CPAN/core modules that have
win32-specific fixes.
The answer is that often Perl distros come with non-core modules. ActiveState in particular is known for doing this. The non-core modules improve usability quite a bit.
Vanilla is the core distro. Strawberry comes with the standard non-standard modules. ;-)
As per Vanilla Perl home page:
In addition to the modules in Vanilla Perl, Strawberry will also include the entire dependency tree for Bundle::CPAN, as well as an additional set of upgraded versions of dual CPAN/core modules that have win32-specific fixes.
From Wiki:
Strawberry Perl is part of the Vanilla Perl Project

How can I install or upgrade a CPAN module that is in the latest Perl, without installing the new Perl?

I'd like to install a Perl module (in this case, FindBin), but since it is included in the Perl 5.10.1 distribution, cpan wants to install Perl 5.10 for me. Is there a way of installing just the module via cpan?
The only option that I can see is installing directly from source, which seems a bit crude as there is no separate package (for example, Makefile.PL, etc.), just the bare .pm file.
Since this is a small module that only has the one file, it's doable in this case, but what if I wanted to install a much larger package?
EDIT: This is somewhat aside from the original question, but speaks to the general issue of modules being packaged up with Perl distributions: I discovered that the "standalone" FindBin (version 1.49) had a syntactic error, so I retrieved version 1.50 out of the Perl 5.10.1 distribution... However since the module is now listed on CPAN as part of Perl 5.10, I am unable to find the CHANGES file describing what was changed/fixed in this delta. Is it reasonable that I should have to go into the developer repository to pull out this information?)
EDIT 2. Okay, here's a better example. On Perl 5.8.8 I have version 1.04 of Carp. However, I see that Perl 5.10.1 comes packaged with version 1.11. Is there a way of getting CPAN to install the latest version of Carp for me without dragging in all of Perl 5.10.1? I can't even find a link to the Carp module on CPAN except to the perl 5.10.1 installation.
> corelist FindBin
FindBin was first released with perl 5.00307
Which version of Perl do you use that does not include FindBin? If you use at least Perl 5.6.0 (all versions before are considered deprecated), you have no need to install FindBin. If you have anything older, I suggest an upgrade to 5.6.2/5.8.9/5.10.1.
Kurila is not a "standalone" FindBin, it's a dialect of Perl. FindBin is not a dual life and is released only bundled with Perl. You can consider releasing FindBin to CPAN as standalone distribution - it is easy if you used ExtUtils::MakeMaker in past.
Latest useful change of FindBin was on 2007-04-28, related to VMS. Latest useful non-VMS change was on 2006-10-25.
Things you can try include
Dropping FindBin.pm into the same directory as your executable and using use FindBin
Dropping FindBin.pm into your Perl library directory
Using the source code of the module in your script