Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a module in Perl

Guys im really confused on how to use a module i just installed in Perl.

I installed a Corelist module in Perl. And i want to display all the modules that came with Perl 5.006. But there is a hint in doing this by using this code which i dont understand:

my %modules = %{ $Module::CoreList::version{5.006} };

But when i did this

#! usr/bin/perl
use warnings;
use strict;

my %modules = %{$Module::CoreList::version{5.006}};

print %modules;

it gives this error: Module::CoreList::version used only once . I also tried putting use Module::CoreList; still no luck

like image 461
ruggedbuteducated Avatar asked Dec 27 '22 03:12

ruggedbuteducated


2 Answers

The name of the module is 'Module::CoreList'. You should put the following line into your programme:

use Module::CoreList;

Also note the capital L. Perl is case sensitive.

like image 87
choroba Avatar answered Jan 12 '23 20:01

choroba


If you simply want to print the hash, just add Data::Dumper module along with strict and warnings, then

print Dumper(\%modules);

Updated: try something like

use warnings;
use strict;
use Module::CoreList;
use Data::Dumper;

my  %module  = %{ $Module::CoreList::version{5.006} };

print Dumper (\%module);
like image 36
Nikhil Jain Avatar answered Jan 12 '23 19:01

Nikhil Jain