perl-module

What Perl module would you be lost without?

What Perl module would you be lost without? ...

Which framework should I use to write modules?

What's the best framework for writing modules -- ExtUtils::MakeMaker (h2xs) or Module::Build? ...

Useful Perl modules

What is the most important module you pull off of CPAN to add to a stock Perl install? One module only per response, please. Please explain why you think the module is best-of-breed ...

How can I update Perl on Windows without losing modules?

At work I'm using Perl 5.8.0 on Windows. When I first put Perl on, I went to CPAN, downloaded all the sources, made a few changes (in the .MAK file? to support threads, or things like that), and did nmake / nmake test / nmake install. Then, bit by bit, I've downloaded individual modules from CPAN and done the nmake dance. So, I'd like ...

How do I make private functions in a Perl module?

I am working on a little Perl module and for some reason I had the test driver script that was using my new module call one of the functions that I thought would be private, and it was successful. I was surprised, so I started searching google and I couldn't really find any documentation on how to make private functions in Perl modules....

How do you debug a mod_perl2 module without restarting?

Environment: Apache/2.2.11 (Win32) mod_apreq2-20051231/2.6.2-dev mod_perl/2.0.4-dev Perl/v5.10.0 Situation very similar to what's described in this discussion list post, except for being on win32. I have this in httpd.conf: PerlModule Apache2::Reload PerlInitHandler Apache2::Reload PerlSetVar ReloadAll Off PerlSetVar ReloadModules "My...

How do I include all/some of the "sub modules" in a Perl script?

I'll just start out by saying I am not at all experienced with creating Perl modules so I'm sorry if I'm way off here. Let's say I am creating a few modules: foo::bar foo::bar::a foo::bar::b Since I don't know what they are called, I am calling the a.pm and b.pm modules "sub modules" since they are related to the bar.pm module, but c...

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 Class::Sniff or Class::Inspector in production. However, Leon's answer is marked as 'accepted' ...

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 modules. However, the following executes fine. perl -e "use XML::Simple " What might be the i...

Mapping values with Column header and row header

Hi, I have some files with below data. sample File 1: sitename1,2009-07-19,"A1",11975,17.23 sitename1,2009-07-19,"A2",11,0.02 sitename1,2009-07-20,"A1",2000,17.23 sitename1,2009-07-20,"A2",538,0.02 I want to map the values in column 4 with column 2 and 3 as shown below. Output required. Site,Type,2009-07-19,2009-07-20 sitename1,"A...

How do you specify a package version in Perl?

I'm a bit confused by conflicting advice between pre-5.10.0 documents and the more recent version module. Perl Best Practices makes it pretty clear that version strings ('v1.0.3') are bad and one is supposed to specify a version as follows: use version; our $VERSION = qv('1.0.3'); but the version module says that we're back to using ...

Why can't my Perl object find its skip() method, even though I can call it as a subroutine?

I'm working on a Perl module and whenever I call the skip() method I wrote in the following way: $cursor->skip(4); I get: Undefined subroutine Perl finds it! Oddly, if I name "skip" anything else ("skipper", "hello"), this syntax works: $cursor->skipper(4); I thought maybe skip() was a "secret" reserved key word or somethi...

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. ...

Using Perl, how can I create charts using values in a CSV file?

I am new to this and need a clue on how to do this task. I have a csv file with following sample data: site,type,2009-01-01,2009-01-02,.... X,A,12,10,... X,B,10,23,... Y,A,20,33,... Y,B,3,12,... and so on.... I want to create a perl script to read data from the csv file (as per the given user input) and create XY(scatter) charts. Let...

How do I refresh an array in a foreach loop?

I am writing a Perl script to do some mathematical operations on a hash. This hash contains the values as given in the sample below. I have written the code below. If I execute this code for an array value separately without using a foreach loop, the output is fine. But if I run this using a foreach loop on the array values, the sum for...

Is there any Perl module that can keep me from adding `or die` to anything that can fail?

I'm writing code that runs all sorts of external commands as well as various filesystem commands that can fail. Is there any module that can save me the trouble of adding or die to anything that can fail? I'd like to be able to wrap the following in something so that instead of: mkdir $dirname or die "can't create directory $dirname"...

Should a Perl constructor return an undef or a "invalid" object?

Question: What is considered to be "Best practice" - and why - of handling errors in a constructor?. "Best Practice" can be a quote from Schwartz, or 50% of CPAN modules use it, etc...; but I'm happy with well reasoned opinion from anyone even if it explains why the common best practice is not really the best approach. As far as my o...

How can I install 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 perl5.10.1 distribution, cpan wants to install perl5.10 for me. Is there any way of installing just the module via cpan? The only option that I can see is installing directly from source, which seems a bit crude as there is no separate package (e...

How do I override perl's compilation flags when building modules?

When building a Perl module ExtUtils::MakeMaker uses the flags defined in Config.pm (see perldoc Config) for values such as ccflags and ldflags. How do I override theses values (short of editing the Makefile.PL)? perl Makefile.PL ldflags=<options> does not seem to work. Context: I am trying to compile Term::Readline::Gnu on OS X 10....

gVim perl tags under Win32 - should I use Perl::Tags ?

Hi, I am a newbie when it comes to gVim, Perl & test scripts, so I hope this is not a stupid question? I have successfully installed Perl::Tags 0.26 under Linux and OS X but am getting installation test errors under WIN32 -- also see perl.cpan.testers My questions are: (i) Does VIM need Perl::Tags or can I rely on exuberant ctags to g...