perl

How can I manually Installing DBD-Oracle 1.17 in ActivePerl on Windows?

After installing Active Perl 5.8.8 Build 822 on WindowsXP, I do not see DBD-Oracle in "View All Packages" of Perl Package Manager. The CPAN location of the same is http://search.cpan.org/dist/DBD-Oracle-1.17/, but I don't know the process to manually install this tar(DBD-Oracle-1.17.tar.gz) in ActivePerl. ...

Are there disadvantages to autodie?

Every now and again I see people on StackOverflow promote the use of autodie. But in the code here and elsewhere in the net I don't see autodie very often. Are there some disadvantages? Do I lose something when using autodie? (I have the idea of getting spoiled, when using autodie) ...

How do I upgrade my MacPorts Perl installation?

I have installed MacPorts in my MacBook Pro with Snow Leopard. I hadn't explicitly installed perl there but I guess it either came installed with the default macports install or was installed as a dependency by any other port I installed. I want to upgrade the Perl v5.8.9 there with the latest stable Perl version. Whichever it may be cu...

How do I access keys by value in a Perl hash of hashes?

I've hash of hash like this: $hashtest{ 1 } = { 0 => "A", 1 => "B", 2 => "C" }; For example, how can I take the value of B of hash{ 1 }? $hashtest{'B'}{1} ...

Why does SQLite give a "database is locked" for a second query in a transaction when using Perl's DBD::SQLite?

Is there a known problem with SQLite giving a "database is locked" error for a second query in a single transaction when using Perl DBD::SQLite? Scenario: Linux, Perl DBI, AutoCommit => 0, a subroutine with two code blocks (using the blocks to localize variable names). In the first code block a query handle is created by prepare() on a s...

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

Is there a problem in perl 5.12.2 using splice on @ISA?

The following is a debug session on Perl 5.12. Does this make any sense? Does UNIVERSAL cache a version of the @ISA variable, which if forever uses thereafer. Back before Class::ISA was deprecated, I used to call Class::ISA::self_and_super_path to get the internals to relook at the @ISA array. Since it is now considered unnecessary, how ...

How do I get and compare stock quotes from Yahoo! and Google?

How to get a history quote from Yahoo and Google Finance with Perl and save in DB to compare and validate. What´s the best/simple Perl/Windows DB to make this and the Perl/Algoritmo to compare this data? ...

How can I open a file only if it is not already open, in Perl?

If I have a subroutine that opens a file what is the best way to ensure it opens it only upon the first time the subrountine is called? I have this but not sure if its best practice: { my $count = 0; sub log_msg { my ($msg,$name) = @_; if ($count == 0) { my $log_file_name = "/tmp/" . $name; open my $log_fh,">",...

How can I conditionally use a module in Perl?

I want to do something like this in Perl: $Module1="ReportHashFile1"; # ReportHashFile1.pm $Module2="ReportHashFile2"; # ReportHashFile2.pm if(Condition1) { use $Module1; } elsif(Condition2) { use $Module2; } ReportHashFile*.pm contains a package ReportHashFile* . Also how to reference an array inside module based on dynamic mod...

Perl: fixing Moose attribute and type coercion problems

I recently upgraded Moose to v1.15 and found that a set of modules I use no longer worked. The error I get is: You cannot coerce an attribute (source) unless its type (GOBO::Node) has a coercion at /opt/local/lib/perl5/site_perl/5.12.0/darwin-multi-2level/Moose/Meta/Role/Application/ToClass.pm line 142 I can see several possible sourc...

Can I extract Tables from PDF using Perl?

I need to extract table objects from PDF documents preferably programmatically using Perl. I am able to cut and paste to Excel, but the table would require quite a bit of manual editing once the data is imported into Excel. I've done some search, but so far it seems though most forums suggest that most APIs are very primitive. ...

How can I make HTTP calls from Perl?

I want to write a Perl script which calls a URL with certain parameters. ...

Why does Perl this program fail to print "Success" when the regex match succeeds?

Hi, I am still a beginner with Perl, so please bear with me. This is the situation I'm experiencing: $var = "AB1234567"; $num = "1234567"; next if $var =~ /$num/; print "Success!\n"; Now, my understanding is that it should print "Success!\n", but in reality it doesn't. However, if I change the regex to next if $var =~ /"$num"/;, this...

How do I invoke a Perl CGI script when the user requests an HTML page?

Is there anyway to invoke a Perl CGI script when an HTML page is requested to server? Just like a script can be tied to an action, is there anyway to tie a script to "Request for page" ...

How can I parse only part of an HTML file and ignore the rest?

In each of 5,000 HTML files I have to get only one line of text, which is line 999. How can I tell the HTML::Parser that I only have to get line 999? </p><h1>dataset 1:</h1> &nbsp;<table border="0" bgcolor="#EFEFEF" leftmargin="15" topmargin="5"><tr> <td><strong>name:</strong>&nbsp;</td> <td width=500> myname one </td></tr>...

How can I automatically tidy up Perl source code?

A cat at my company walked over a keyboard and has left a valid 1000+ line of executable Perl code for me to maintain. Thanks to Perl's TMTOWTDI philosophy I find myself searching Google to make sense of every line of code she has produced. To add to my misery the code is not indented and one find frequent occurrence of the two stateme...

How to get the name of the input file in a Perl one-liner?

cat monday.csv 223.22;1256.4 227.08;1244.8 228.08;1244.7 229.13;1255.0 227.89;1243.2 224.77;1277.8 cat tuesday.csv 227.02;1266.3 227.09;1234.9 225.18;1244.7 224.13;1255.3 228.59;1263.2 224.70;1247.6 This Perl one-liner gives me the row with the highest value in the second column from the rows where in...

How can I extract the contents of a specific table from HTML source using Perl?

I have to parse 5000 files - which look pretty identical. I like using HTML::TokeParser::Simple and DBI in order to do the parsing job and store the results. I have little experience with HTML::TokeParser::Simple but this task goes over my head. Note: i also have had a look at the ideas - that seems to be also an appropiate way. But at...

Mechanize::Firefox gets stuck

I'm using WWW::Mechanize::Firefox to crawl pages that load some JavaScript after they have been loaded. My code regarding this problem: my ($firemech) = WWW::Mechanize::Firefox->new(tab => 'current', ); $firemech->get($url); die "Cannot connect to $url\n" if !$firemech->success(); print "I'm connected!\n"; my ($retries) = 10; while ($...