emp1953 has asked for the wisdom of the Perl Monks concerning the following question:

I am running Fedora 19, checking the Perl version says I have version 5.16 What is wrong with my Perl installation? I have copied several simple scripts from various web sites. All fail to run, on line 4 where it says "use xxxx::class" etc error follows:

Can't locate Path/Class.pm in @INC (@INC contains: /usr/local/lib64/pe +rl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/pe +rl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./perl_exampl +e.pl line 4. BEGIN failed--compilation aborted at ./perl_example.pl line 4.

THIS IS ONE OF THE SCRIPTS

#!/usr/bin/perl use strict; use warnings; use Path::Class; my $dir = dir('foo','bar'); # foo/bar # Iterate over the content of foo/bar while (my $file = $dir->next) { # See if it is a directory and skip next if $file->is_dir(); # Print out the file name and path print $file->stringify . "\n"; }

Replies are listed 'Best First'.
Re: My Perl installation does not work
by Athanasius (Archbishop) on Jan 17, 2017 at 04:22 UTC

    Hello emp1953, and welcome to the Monastery!

    One of the strengths of Perl is the , which, according to Wikipedia,

    is a repository of over 250,000 software modules and accompanying documentation for 39,000 distributions, written in the Perl programming language by over 12,000 contributors.

    Clearly, there are too many modules to include them all in a Perl distribution, so users download and install CPAN modules as needed. In this particular case, issuing either

    cpan Path::Class

    or

    cpanm Path::Class

    from the shell (command line) will install the missing module (assuming you have an internet connection) and allow the script to run correctly. See How do I install a module from CPAN?

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: My Perl installation does not work
by kevbot (Vicar) on Jan 17, 2017 at 04:34 UTC
    I see that Athanasius already demonstrated how to install a module using the cpan or cpanm commands. Alternatively, you could look for a Fedora package (some CPAN modules are provided as packages by the vendor). Look for a package name that starts with perl-Path-Class.
Re: My Perl installation does not work
by morgon (Priest) on Jan 18, 2017 at 03:15 UTC
    Lucky you!

    My installation works just fine but many times my scripts don't work.

    That's much harder to fix.