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
9
votes
2 answers

How can I 'use' specific version of a perl CPAN module?

I have a lot perl code that does different things in test and production, and I want to lock my code to specific versions of CPAN modules in case there are some changes to some of them in the future which may possibly break my code. So I want to…
Gogi
  • 1,695
  • 4
  • 23
  • 36
8
votes
2 answers

In Test::More, is it possible to test a subroutine that exit()'s at the end?

I have a module that I wrote with some utility functions. One of the functions is just a usage statement (recommended by user @zdim) use 5.008_008; use strict; use warnings; # Function Name: 'usage' # Function Inputs: 'none' # Function…
Speeddymon
  • 496
  • 2
  • 20
8
votes
3 answers

How do I use a certain version (or higher) of a perl module in my perl script?

I'm using Term::ANSIColor in my Perl script to do colorization of terminal output, and I am using the colorstrip function, which was only added in Term::ANSIColor version 2.01, according to the changelog. So, is there a way to make my script…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
8
votes
3 answers

Is it proper to get and especially set Perl module's global variables directly?

I was wondering what the best practice in Perl is regarding getting - or, more importantly, setting - a global variable of some module by directly accessing $Module::varName in case the module didn't provide getter/setter method for it. The reason…
DVK
  • 126,886
  • 32
  • 213
  • 327
8
votes
3 answers

Why does Perl warn about "useless constant 1" when using bigint?

I was writing a module as part of my application when I noticed syntax check results in warning about useless use of a constant (1). Why is that? The constant is the obligatory 1 at the end of the module which is normally ignored by warnings as…
Daniel Böhmer
  • 14,463
  • 5
  • 36
  • 46
8
votes
2 answers

How can I call functions in a different C source file from a Perl XS module?

I am building an XS extension with Perl. I have two files: A C header file (.h) A C source file (.c) Currently what i did is to put all the C file code before the Model= on the XS file and wrap the functions I want after the Model=. The…
smith
  • 3,232
  • 26
  • 55
8
votes
3 answers

progress bar in command line perl script

I am trying to print progress in % in command prompt. But it is not working properly. I want to print the progress as :: Status 10% Completed when 20% will complete it will show Status 20% Completed in that same place not in new line. Could you…
r-developer
  • 517
  • 1
  • 8
  • 21
8
votes
1 answer

same warning multiple times when package in @ISA is not loaded

while refactoring some of my perl code i noticed the following strang behaviour. consider this small sample script: #!/usr/bin/perl -w package test; use strict; my $obj = bless( {}, __PACKAGE__); our @ISA = qw( missing ); exit(0) the expected…
Nico Rittner
  • 189
  • 5
8
votes
2 answers

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…
Ether
  • 53,118
  • 13
  • 86
  • 159
8
votes
4 answers

How do I find all modules used in a Perl script and install them?

I have been given a few Perl scripts to deploy. What is the easiest way to find and install all modules used by these scripts? EDIT: From what I can find there are no conditional includes or includes in evals.
Nifle
  • 11,745
  • 10
  • 75
  • 100
7
votes
2 answers

What does Perl do when two versions of a module are installed?

I don't have root access on a remote box I'm working with, so I'm using a combination of cpanm and local::lib as described here to install CPAN modules to my local directory on the box. Using cpanm, I assume cpanm Module::To::Update would install…
gempesaw
  • 329
  • 3
  • 12
7
votes
1 answer

Perl Cygwin fun. Module is loaded, but not being found by the program

Okay a few rules: No, I cannot install Strawberry Perl on this system. I have to use Cygwin. This is Perl 5.8.7. I cannot update it. This is not my system. This is a customer's system, and I cannot modify it to my hearts content. Now, we've gotten…
David W.
  • 105,218
  • 39
  • 216
  • 337
7
votes
1 answer

What does the `X` suffix mean in namespaces?

There are Perl module names like Moose and MooseX or DBI and DBIx or Catalyst and CatalystX or Mojo and MojoX or PPI and PPIx, etc. What does the X suffix mean there?
w.k
  • 8,218
  • 4
  • 32
  • 55
7
votes
3 answers

Can I dynamically get a list of functions or function names from any Perl module?

I would like to dynamically get a list of either function names (as strings) or function references from any arbitrary Perl module available on my system. This would include modules that may or may not have, e.g., a global @EXPORT_OK array in its…
Richard Simões
  • 12,401
  • 6
  • 41
  • 50
7
votes
4 answers

In Perl, how can I access a scalar defined in another package?

I seem to be stuck trying to access a scalar which is defined in another package, and have narrowed down an example to a simple test case where I can reproduce the issue. What I wish to be able to do it access a reference to a list which is in…
user441369
  • 85
  • 1
  • 1
  • 3