perl

How can I do the pagination in my Perl CGI script?

I have a CGI page with a table which is populated by fetching the data from database, in a word its like a DATAGRID. And just at the bottom right end of tha Grid I need a link like "First << 1 2 >> Last" or like" |< < > >| "on clicking which I can navigate to and fro the records. And I am intend to have "10" records per page. While sur...

How can I install Perl version under my home using perlbrew?

I have installed perlbrew which seems like a good solution, but I get some meaningless error when actually trying to install some Perl version: $ perlbrew install perl-5.12.1 Attempting to load conf from /home/dave/perl5/perlbrew/Conf.pm Fail to get http://search.cpan.org/dist/perl-5.12.1 (error: ) at /home/dave/perl5/perlbrew/bin/perl...

Why can't I call my exported subroutine in my Perl program?

I am new to Perl and I face following issue, having no clue why following is not working. My Perl module contains: package PACK2; use Exporter; @ISA = ('Exporter'); @EXPORT_OK=('whom'); sub why(){ print "why\n"; } sub whom(){ print "whom\n"; } 1; My Perl file contains: #!/usr/bin/perl -w use pack; use pack2 ('whom'); P...

How can I pass a filehandle to Perl Expect's log_file function?

I feel stupid for asking this, but I've tried a couple things and I'm not sure where to go with it. From the Expect.pm documentation: $object->log_file("filename" | $filehandle | \&coderef | undef) Log session to a file. All characters send to or received from the spawned process are written to the file. I'd like to pass t...

Where can I find application runtime errors using Nginx, Starman, Plack and Catalyst?

I have managed successfully to server my Catalyst app on my development machine using Plack + Starman, using a daemon script I based on one I found in Dave Rolsky's Silki distribution. I then set up nginx to reverse proxy to my Starman server, and aliased the static directory for nginx to serve. So far, so good. However, I am at a loss ...

Why doesn't my Perl blessed filehandle doesn't return true with `can('print')`'?

For some reason, I can't get filehandles working with Expect.pm's log_file method. I originally got help on How can I pass a filehandle to Perl Expect's log_file function?, where it was suggested that I use an IO::Handle filehandle to pass to the method. This seems to be a different issue, so I thought I'd start a new question. This i...

Perl ithreads: Do some math instead of sleeping

I am using perl ithreads and things work fine, unless I decide to have threads sleep. Lets say my routine thread_job is passed as an entry for several threads to start running concurrently. thread_job() { ... sleep 2; #do other stuff here } If I dont have a sleep I have no issues with the threads running and they do their tasks f...

Why does Perl's MIME::Lite fail with " SMTP data() command failed: 2.1.5 ... Recipient ok"?

This is probably a crossover question that is valid for both SO and SF. I am using a Perl script as follows to send e-mail: my $SMTP_SERVER = 'xx.xx.xx.xx'; my $DEFAULT_SENDER = '[email protected]'; my $DEFAULT_RECIPIENT = '[email protected]'; ### Create the multipart "container": $msg = MIME::Lite->new( From =>$DEFAULT_SENDER, T...

What does it mean to have uselongdouble undefined, but d_longdbl defined in the Perl build configuration?

Most of the perl installations I use have uselongdouble undefined, but d_longdbl defined. Literally I guess this means that long doubles are not used as the default floating point type, but long doubles are 'supported'. I'm confused though about what it means for long doubles to be 'supported'. As far as I know, Perl doesn't have any mec...

How can I enable Perl web scripts to run on Apache?

I have a Perl script which is scripted to print "Hello!" on a web browser. I am using apache as my localhost server. The OS I am using is the Red Hat 5. The problem is that when I type the address http://localhost/example.pl or http://127.0.0.1/example.pl, it shows me exactly the entire script codes but not the "Hello!" word that should...

Why does LWP::UserAgent GET request fail with HTTPS?

Hi, Here's my code #!/path/to/perl use strict; use LWP::UserAgent; use HTTP::Request::Common; use Crypt::SSLeay; $ENV{HTTPS_PROXY} = 'http://proxy:8080/'; $ENV{HTTPS_DEBUG} = 1; my $myurl = "https://www.redhat.com"; my $ua = new LWP::UserAgent; $ua->cookie_jar( {} ); $ua->protocols_allowed( [ 'http','https'] ); $ua->proxy(['http'...

How to format perl code?

I really like my Perl code formatted - lines indented, etc. The problem is I hate doing it myself, and I really enjoy auto-formatters that do this automatically for you. I work with Eclipse and the EPIC plugin does just that. The problem is that it does not handle comments very well. If comments are too long, it does not break them into...

How do I use Perl's smart matching to match many patterns at once?

I was trying to follow some examples to use smart matching in the following piece of code, but failed (nothing was filtered out). my $regexes_to_filter_a = ("tmp", "temp", "del") my @organism_dirs = (); # this will hold final list of dirs to processs my @subdirs = File::Find::Rule->directory->maxdepth(1)->in($root_dir); foreach my $sub...

How can I avoid warnings in Perl?

I have a small piece of code for printing the contents in a text file like this, use strict; use warnings; open (FILE, "2.txt") || die "$!\n"; my $var = <FILE>; while ($var ne "") { print "$var"; $var = <FILE>; } Text file is, line 1 line 2 line 3 After running the code i am getting a warning like this, line 1 line 2 l...

excel with Japanese(wide) fonts

I was working on parsing an excel file having japanese files in some of the cells. By using Spreadsheet::ParseExcel (Ver. 0.15) (which I know is older than current version) some of the cells with below characters <設定B-1コース> are appearing as in print Dumper $oWkc->{_Value}; $VAR1 = "\x{ff1c}\x{8a2d}\x{5b9a}B-\x{ff11}\x{30b3}\x{...

How can I use Perl's WWW::Mechanize to check if a web page has been updated?

I'm using WWW::Mechanize to retrieve a webpage. I need to check if the page has been updated and retreive information from it. How can I do this? ...

How to improve the usage of lock_keys in Perl?

I'm using Hash::Util's lock_keys to die whenever trying to access a non-existing key in a hash. Sometimes my hashes are deep (hash of hashes of hashes...). Is there a quick method to lock them all at once? Is it possible to control the default message upon failure (i.e. add a Dump of the hash in which the key wasn't found) ...

Is it safe to thread after forking?

I've learned that you should usually stick with either forking or threading to avoid running into very strange and extremely hard-to-debug problems, so until now I always did exactly that. My problem with the matter is that when I stick with only forking, creating many short-lived processes to distribute chunks of work to gets the more e...

How do I retrieve a value from nested divs tags with Perl's HTML::TokeParser?

I'm using the HTML::TokeParser to parse an HTML file and get data within div tags. My HTML is as follows: <div class='t_and_h f_t' id='t_f_i'> <div class='icon'> <img alt="icon" src=""/> </div> <div class='t'> 12:31 PM </div> <div class='h'> <a>Residue 4</a> </div> <div class='f_t'> TRUE </div> </div> M...

How can I loop through a Perl array of arrays of hashes?

I would like to print an Array of Arrays of Hashes, so I looked at perldsc, and ended up with for my $j (0 .. $#aoaoh) { for my $aref (@aoaoh) { print '"' . join('","', @$aref[$j]), "\"\n"; } } but it doesn't work. Does anyone know how to do this? ...