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
214
votes
3 answers

How is Perl's @INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)

What are all the ways of affecting where Perl modules are searched for? or, How is Perl's @INC constructed? As we know, Perl uses @INC array containing directory names to determine where to search for Perl module files. There does not seem to be a…
DVK
  • 126,886
  • 32
  • 213
  • 327
108
votes
27 answers

How do I get a list of installed CPAN modules?

Aside from trying perldoc individually for any CPAN module that takes my fancy or going through the file system and looking at the directories, I have no idea what modules we have installed. What's the easiest way to just get a big…
David McLaughlin
  • 5,108
  • 4
  • 34
  • 35
100
votes
2 answers

In Perl, what is the difference between a .pm (Perl module) and .pl (Perl script) file?

What is the Difference between .pm (Perl module) and .pl (Perl script) file? Please also tell me why we return 1 from file. If return 2 or anything else, it's not generating any error, so why do we return 1 from Perl module?
user380979
  • 1,387
  • 5
  • 16
  • 20
76
votes
11 answers

How can I check if a Perl module is installed on my system from the command line?

I tried to check if XML::Simple is installed in my system or not. perl -e 'while (<@INC>) { while (<$_/*.pm>) { print "$_\n"; } }' The above one-liner was used for listing all modules installed in my system. However, it is not listing XML…
joe
  • 34,529
  • 29
  • 100
  • 137
74
votes
4 answers

Installing modules using Strawberry Perl

Until now I used ActiveState's ActivePerl, and used the ppm for installing modules. Last week I moved to Strawberry Perl, but I don't know how I should install modules using Strawberry Perl. What is some information on how module installation is…
ronssd
  • 741
  • 1
  • 5
  • 3
41
votes
5 answers

How do I install Perl libraries in Cygwin?

I'm a C/C++/Java/Unix geek by trade, but now I have to write a Perl program in Windows. So I've got Cygwin, Eclipse with EPIC installed, and simple test programs run. I do not have a Unix machine available to me that I can run Eclipse on. But I need…
stu
  • 8,461
  • 18
  • 74
  • 112
38
votes
7 answers

What does "1;" mean in Perl?

I have come across a few Perl modules that for example look similar to the following code: package MyPackage; use strict; use warnings; use constant PERL510 => ( $] >= 5.0100 ); require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(…
Anand Shah
  • 14,575
  • 16
  • 72
  • 110
37
votes
4 answers

Why the 1 at the end of each perl package?

If you forget the 1 at the end of a package, Perl tells you "The package didn't return a true value". Well, if it knows you forgot it, why not just put it there for you?
miniml
  • 1,489
  • 2
  • 17
  • 27
35
votes
4 answers

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

For some reason, whenever I run any Perl module (like cpanm), I've been getting this response: ListUtil.c: loadable library and perl binaries are mismatched (got handshake key 0xdb00080, needed 0xdb80080) I'm not sure why this is…
javathunderman
  • 1,074
  • 2
  • 13
  • 31
35
votes
7 answers

Can't locate Switch.pm

How do I solve this error? Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18…
Deepak Singh
  • 1,079
  • 2
  • 11
  • 15
34
votes
6 answers

Can't locate DBI.pm

I'm trying to launch this script: #!/usr/bin/perl use DBI; my $dbh = DBI->connect( 'dbi:Oracle:host=lonlin2;sid=TIMFX1AD;port=1524','xbsesdbo','xbsesdbo123' ) || die ( $DBI::errstr . "\n" ); my $query= "SELECT * FROM product_elements WHERE…
chaw359
  • 505
  • 1
  • 5
  • 14
32
votes
2 answers

export vs export_ok in perl

I can not understand what is the difference/use case of EXPORT_OK vs EXPORT. Most resources mentions something in the lines of: @Export allows to export the functions and variables of modules to user’s namespace using the standard import…
Jim
  • 18,826
  • 34
  • 135
  • 254
30
votes
4 answers

In Perl, how do I put multiple packages in a single .pm file?

I'm pretty sure that I read somewhere that it's possible, but there are a few gotchas that you need to be aware of. Unfortunately, I can't find the tutorial or page that described what you need to do. I looked through the Perl tutorials, and didn't…
Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
24
votes
3 answers

What's the best way to discover all subroutines a Perl module has?

What's the best way to programatically discover all of the subroutines a perl module has? This could be a module, a class (no @EXPORT), or anything in-between. Edit: All of the methods below look like they will work. I'd probably use the …
Robert P
  • 15,707
  • 10
  • 68
  • 112
24
votes
9 answers

How we can create a Unique Id in Perl

I want to create a UniqueId. Is there a function I can call, such that every time when I use that it will give me a new Id, always with a different value?
user2568702
1
2 3
90 91