Questions tagged [perl-module]

A Perl module is a reusable portion of Perl code.

In Perl, modules are vital to object-oriented design and can provide static variables referenced similarly to those in C++. The package model improves code organization, by allowing the coder to import functions from external files and 'bless' new object instances. Further, perl allows the directory structure holding modules to aid in the description of an object hierarchy. Perl module files traditionally have the extension '.pm'

see perlmod - perldoc.perl.org for more information.

1358 questions
10
votes
2 answers

How to get rid of 'Name ... used only once: possible typo at ...'?

use YAML::XS; local $YAML::XS::DumpCode=1; ... I get the warning: Name "YAML::XS::DumpCode" used only once: possible typo at .. Well, I know I can suppress this specific warning, but it's kind'a ugly. Am I doing anything wrong? I'm not used to be…
David B
  • 29,258
  • 50
  • 133
  • 186
10
votes
4 answers

Giving Credit for Perl Module

I wrote a script for my company and I am using some libraries I obtained from CPAN. My manager wanted me to consolidate and remove the extra libraries - which is a little funny because I include them for the script to work. A few notes: I do not…
rusty
  • 307
  • 1
  • 4
  • 16
10
votes
4 answers

How should I organize many Perl modules?

Consider that I have 100 Perl modules in 12 directories. But, looking into the main Perl script, it looks like 100 use p1 ; use p2 ; etc. What is the to best way to solve this issue?
joe
  • 34,529
  • 29
  • 100
  • 137
10
votes
6 answers

purpose of installing a perl module with apt-get instead of cpan

While loading necessities into my crouton, apt-get recommended that I install libtemplate-perl. This seemed a jolly idea, and I obeyed. Reading this answer, I see a fellow traveler install Plack and Starman via CPAN, but then use apt-get to install…
Cody Hess
  • 1,777
  • 15
  • 19
10
votes
3 answers

Difference between use and require (I listed the differences, need to know what else are there)

I read the explanation even from perldoc and StackOverflow. But there is a little confusion. use normally loads the module at compile time whereas require does at run time use calls the import function inbuilt only whereas require need to call…
Sumit
  • 1,953
  • 6
  • 32
  • 58
10
votes
3 answers

Can't locate local/lib.pm in @INC at /usr/share/perl/5.14/CPAN/FirstTime.pm

I am trying to use Perl the first time on my system which is Ubuntu 12.04. I have Perl v.5.14.2 installed. I looked up how to install Perl modules, so I started as follows: $ perl -MCPAN -e shell The wizard started configuring the environment as…
JJD
  • 50,076
  • 60
  • 203
  • 339
10
votes
2 answers

Perl one liner to extract a multi-line pattern

I have a pattern in a file as follows which can/cannot span over multiple lines : abcd25 ef_gh ( fg*_h hj_b* hj ) { What I have tried : perl -nle 'print while m/^\s*(\w+)\s+(\w+?)\s*(([\w-0-9,* \s]))\s{/gm' I dont know what the flags mean…
Gil
  • 1,518
  • 4
  • 16
  • 32
9
votes
2 answers

Perl Module usage

I am trying to create my own Perl module in /usr/local/lib/perl I have the environmental variable PERL5LIB set: $ env | grep PERL PERL5LIB=/usr/local/lib/perl If I create a module: $PERL5LIB/My/ModuleTest.pm $ ./test.pl Can't locate object method…
Mose
  • 541
  • 1
  • 11
  • 27
9
votes
2 answers

Is there any implementation of database by perl

Is there any perl modules implementing function of database and easy to use. I do not need modules used to connect to some database products. I need simple database writing by perl. Thanks.
user2799433
  • 171
  • 11
9
votes
2 answers

Cwd.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed 0xde00080)

All Perl modules and 'cpan' stopped working after an upgrade of Ubuntu 16.04 LTS to 18.04 LTS. Every time I run my script it leads to the error threads.c: loadable library and Perl binaries are mismatched (got handshake key 0xdb00080, needed…
Pradyumna Sagar
  • 365
  • 3
  • 10
9
votes
2 answers

Can I use a module, and later unload it shrinking the optree?

Disclaimer I'm not sure I'm using the right terms. It may not be the optree responsible for the bloat mentioned below: it may be the symbols loaded by DynaLoader that are not freed. Is it possible to use a module, like POSIX.pm, unload it and lessen…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
9
votes
1 answer

Scalar::Util vs. ref function

What's the difference between the built in ref($object) and Scalar::Util blessed($object)? Is one preferred over the other? use strict; use warnings; use Scalar::Util qw(blessed isvstring); my $object = foo->new(); print "Object is a " .…
David W.
  • 105,218
  • 39
  • 216
  • 337
9
votes
4 answers

Upgrade Perl from 5.6 to 5.24

We are currently using 5.6 version of Perl in our organisation, along with MySQL and Apache, but now the client wants to upgrade Perl to v5.24. What are all the major changes and key points that must be kept in mind before starting an upgrade? I…
user2659500
  • 93
  • 1
  • 6
9
votes
3 answers

What is the most efficient way to export all constants (Readonly variables) from Perl module

I am looking the most efficient and readable way to export all constants from my separate module,that is used only for storing constants. For instance use strict; use warnings; use Readonly; Readonly our $MY_CONSTANT1 =>…
CROSP
  • 4,499
  • 4
  • 38
  • 89
9
votes
1 answer

Does every Perl module in a distribution need to have a version number?

I'm maintaining a CPAN distribution that has over 100 .pm files. Do each of them need to have a $VERSION, or is it okay to just include it in the main module? For the other modules in the distribution, what effect does including or not including…
Steve Simms
  • 826
  • 5
  • 5