perl-module

Stopping Perl XS modules from silently falling back to pure-perl

It seems some (many?) modules on CPAN are partly implemented in C using XS, and can fall back to a pure-perl implementation if necessary. While this is smart, it can obviously hurt performance, and I would like to know it happens so I can fix the problem. Is there a general way of stopping or detecting this type of fallback? For an exa...

Fetch <td> text while using WWW::Mechanize to fetch <a> within that <td> tag

Hi experts, I'm new to Perl-HTML things. I'm trying to fetch both the texts and links from a HTML table. Here is the HTML structure: <td>Td-Text <br> <a href="Link-I-Want" title="title-I-Want">A-Text</a> </td> I've figured out that WWW::Mechanize is the easiest module to fetch things I need from the <a> part, but I'm not su...

Is there documentation for writing tests (and building) with Module::Build?

So I've made a few modules for my own use, and I'm wondering if there is any documentation about how to write tests for perl modules using Module::Build. The specific problem I'm running into is that I've got three modules, HomeBrew::IO, HomeBrew::Stats, and HomeBrew::Bio, and I can't figure out how to build or test them separately th...

extract all links from a HTML page, exclude links from a specific table

Hi experts, I'm pretty new to Perl/HTML. Here is what I'm trying to do with WWW::Mechanize and HTML::TreeBuilder: For each chemical element page on Wikipedia, I need to extract all hyperlinks that point to the other chemical elements' pages on wiki and print each unique pair in this format: Atomic_Number1 (Chemical Element Title1) -> ...

Old .pl modules versus new .pm modules

Im a beginner in Perl and I'm trying to build in my head the better ways of structuring a perl program. I'm proficient in Python and I'm used to the python from foo import bar way of importing functions and classes from python modules. As I understood in perl there are many ways of doing this, .pm and .pl modules, EXPORTs and @ISAs, use...

How do I use Perl's Google::Search to look for specific URLs?

The Google::Search module, which is based on the AJAX Search API, doesn't seems to work very well, or it is just me? For example, I use firefox to search google for: http://bloggingheads.tv/forum/member.php?u=12129 It brings results. But when I use the module this way: $google_search = Google::Search->Web ( q => "http://bloggingheads...

How do I read args passed to the constructor and args passed by `use Module` in Perl?

Currently I am making a new module and I was wondering how could I implement in my module 2 things. We often see the use like: use My::Module qw(something); for example: use CGI::Carp qw(fatalsToBrowser); So the first question is, how do i retrieve this, i mean wether the user has specified anything and what he specified ? Second...

How can I parse user-agent strings in Perl?

I need to parse the user-agents in HTTP-headers from a text file so as to determine the browser, the version, the OS and possibly the device. so few examples of those lines are: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Update a; AOL 6.0; Windows 98) User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Crazy Browser...

Feedback, question about my module and if i should change anything ?

package My::Module; # $Id$ use strict; use Carp; use Data::Dumper; use DBI; $My::Module::VERSION = '0.1'; sub new { my ($class, %opt) = @_; my $opt_count = keys %opt; $class->set_error(''); #return $class->set_error("Too many arguments to initialize.") if ($opt_count > 5); #return $class->set_error("Missing argu...

How can I hook into Perl's use/require so I can throw an exception?

If a file is already loaded, is there anyway to hook into the use/require so I can throw an exception? In my upcoming nextgen::blacklist, I'm trying to die if certain modules are used. I'm using the object-hook method as mentioned in perldoc -f require: there are three-like hooks object, array with subref, and subref. The example in this...

How should I handle errors inside or outside a Perl module?

I started learning how to make a module in perl with perltoot: package Person; use strict; my($NAME, $AGE, $PEERS) = ( 0 .. 2 ); sub new { my $self = []; $self->[$NAME] = undef; $self->[$AGE] = undef; $self->[$PEERS] = []; bless($self); return $self; } sub name { my $self = shift; if (@_) { $self...

Perl application installation

I have written a small perl application for deployment on a few servers. It consists of some scripts, some modules and some data files. It will be used by multiple users. I'd like to keep all these files together in one directory rather than moving the app modules to the site_perl directory. For example, lets say the application consist...

How can I set a default value for a Perl variable?

I am completely new to Perl. I needed to use an external module HTTP::BrowserDetect. I was testing some code and tried to get the name of the OS from os_string method. So, I simply initialized the object and created a variable to store the value returned. my $ua = HTTP::BrowserDetect->new($user_agent); my $os_name = $ua->os_string(); ...

Why does Perl's Net::SFTP->new complain about "Not an ARRAY reference"?

I am trying to use Net::SFTP to get connected to remote server. My script is: my %args = ( ssh_args => { user => 'canneu_scp', identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], debug => 1, } ); my $targetserver='files.responsys.net'; my $sftp = Net::SFTP->new($targetserver, %args)...

How can I install DBD::Pg if postgres is not installed?

I have a separate servers running with postgres and Nagios. I want to use "psql_replication_check.pl" with nagios to monitor the postgres replication status. This check script requires DBD::Pg module to connect to database. Installation of DBD::Pg asking for the path of pg_config file. #perl Makefile.PL Configuring DBD::Pg 2.17.1 Path ...

OOP question: Calling a subroutine?

I have been thrust into taking over some code but I may be out of my element in figuring this one out. If someone could give me a hint I'd appreciate it. I'm enjoying learning this code but every now and then I need a push. When looking through this code I came across this line: my @files = My::Module::DB::raw_info->search_like(custom...