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
7
votes
1 answer

What is the default path for cpanm to install Perl modules?

Before I use cpanm to install some Perl modules on a "new" (to me) system, I would like to know where they will get installed by default. I don't see any kind of a dry-run option, which is what I'd hoped for. perl -V includes this %ENV and @INC…
Randall
  • 2,859
  • 1
  • 21
  • 24
7
votes
6 answers

Calling a subroutine in OOP Perl

When looking through some code I took over, I came across this line: my @files = My::Module::DB::raw_info->search_like(customer_handle => $config->{client}, feed => $config->{site}, arrival =>"$date") I know that this returns an array from a…
Jane Wilkie
  • 1,703
  • 3
  • 25
  • 49
7
votes
4 answers

Create combinations from elements in an array

I have an array reference like below: my $strings = [qw(a b c d)]; I want to form all possible combination and create an array of array as: my $output = [qw(qw([a],[b],[c],[d],[a,b],[a,c],[a,d],[b,c],[b,d],[c,d], …
questionar
  • 274
  • 2
  • 18
7
votes
2 answers

Why does use statement in sub apply globally?

use WWW::Mechanize; $mech = new WWW::Mechanize; $mech->get("http://www.google.com"); $html = HTML::TreeBuilder::XPath->new_from_content($mech->content); sub test { use HTML::TreeBuilder::XPath; } The above code compiles, so the use statement in…
CJ7
  • 22,579
  • 65
  • 193
  • 321
7
votes
4 answers

Perl - Package/Module Issues

From everything I've read on using Perl modules, the basic usage is: Module file with .pm extension, which includes the statement package , where is the filename of the module without the extension. Code file that uses module contains…
brydgesk
  • 864
  • 1
  • 8
  • 14
7
votes
3 answers

Defining common variables across multiple scripts?

I have a number of Bash and Perl scripts which are unrelated in functionality, but are related in that they work within the same project. The fact that they work in the same project means that I commonly specify the same directories, the same…
forquare
  • 324
  • 2
  • 16
7
votes
4 answers

Is there a better way to pass by reference in Perl?

I am doing pass-by-reference like this: use strict; use warnings; sub repl { local *line = \$_[0]; our $line; $line = "new value"; } sub doRepl { my ($replFunc) = @_; my $foo = "old value"; $replFunc->($foo); print $foo; #…
JoelFan
  • 37,465
  • 35
  • 132
  • 205
7
votes
2 answers

Perl module - dist.ini and platform specific prereqs

How can I add conditional prereqs to dist.ini for each platform (Windows/Non windows) I want the module to support? For example in perl code I could do: if ( $^0 eq 'MSWin32' ){ require Win32::Foo; }else{ require Bar::Baz; } How do I cater…
Dr.Avalanche
  • 1,944
  • 2
  • 28
  • 37
7
votes
2 answers

Determining modules loaded once program starts

I have a forking server. I load all modules before I fork. ...or do I? I want a message to be logged to STDERR for every module loaded after a certain point in my program. I was going to use the following, but it's logging some scripts executed…
ikegami
  • 367,544
  • 15
  • 269
  • 518
7
votes
2 answers

Should I put core modules in the PREREQ_PM section of a Makefile.PL?

Should I put only non-core modules in the PREREQ_PM section of a Makefile.PL or should I put there the core modules too?
sid_com
  • 24,137
  • 26
  • 96
  • 187
7
votes
3 answers

How can I tell what modules were originally provided with the specific Perl installation on a machine?

How can I tell what modules were originally provided with the specific Perl installation on a machine? (This is not a duplicate of: How can I tell if a Perl module is core or part of the standard install? ( "How can I tell if a Perl module is core…
therobyouknow
  • 6,604
  • 13
  • 56
  • 73
7
votes
1 answer

Perl: use Module @list

Someone has an idea to use array variable in place of array (list) literal, in the use function statement, like: my @list = qw(foo zoo); use Module @list; instead of use Module qw(foo zoo); So she writes e.g.: my @consts = qw(PF_INET…
mykhal
  • 19,175
  • 11
  • 72
  • 80
7
votes
1 answer

Is there an actual derived class at runtime in Perl?

I am looking into Perl OO (new to Perl). I created a trivial example hierarchy: Parent class: #!usr/bin/perl use strict; use warnings; package Objs::Employee; my $started; sub new { my ($class) = @_; my $cur_time =…
Cratylus
  • 52,998
  • 69
  • 209
  • 339
7
votes
4 answers

What is @ISA in Perl?

If I have a module with methods a and b and want to export them I do: use Exporter; our @ISA = qw (Exporter); our @EXPORT = qw (a b); What I don't understand is what does this line: our @ISA = qw (Exporter); do?
Jim
  • 18,826
  • 34
  • 135
  • 254
7
votes
2 answers

Perl can't find module when run from cron.daily

I have perl programs that use Net::Finger and have run successfully from cron.daily in Fedora 11. I just upgraded a server to Fedora 18 and these same perl programs no longer run from cron but run fine from command line when logged in as root. The…
Xi Vix
  • 1,381
  • 6
  • 24
  • 43