perl

How can my Perl script use Amazon clouds?

I want my Perl script can handle a large number of users. I'm going to run the script on Amazon clouds servers. This is my understanding of how the clouds work. At first the script instances are run on a single server. Then at the moment the server gets overloaded by too many users, the second server is added to run script instances. Do...

Is there a way to identify a USB pnp event in Perl code on Windows?

Is anyone familiar with how to identify a USB pnp event with Perl on a Windows (win32 system)? There is Device::USB (Use libusb to access USB devices) but it suitable for linux, and in order to work in Windows it require libusb and even that not require it to works, is there any other option to identify if a USB device is plugged or un...

Can I force further XML parsing in SOAP::Lite?

I'm trying to write a simple SOAP client using SOAP::Lite. After making a request, the response only seems to be parsed into perl data structure a couple levels down. After that it's just a string of the remaining XML. I feel like it would be really kludgy to take that string and parse it manually with another XML parser. my $response...

How can I make Module::Build install both X and X::Y?

If I have a distribution with X and X::Y also in it, how do I make Module::Build install both the modules? I have put X.pm in lib, written a file Build.PL with the line my $build = Module::Build->new ( module_name => "X", ); This installs X OK, but how do I tell Module::Build to also include X::Y in the distribution? ...

Does Perl's IO::Select in Windows work with filehandles?

Does IO::Select in Windows work with filehandles? $pid = open $handle, "-|", "$_command" || die "Cannot run $_command"; my $s = IO::Select->new(); $s->add($handle); $s->add(\*STDIN); while (1) { @ready = $s->can_read(30); if (scalar(@ready) > 0) { } else { } } My script continuously prints something to the screen, ...

Why does my UTF8 data from my mod_perl application still get garbled in the web browser?

Before I begin, I would like to highlight the structure of what I am working with. There is a text file from which a specific text is taken. The file is encoded in utf-8 Perl takes the file and prints it into a page. Everything is displayed as it should be. Perl is set to use utf-8 The web page Perl generates has the following header <...

What's the best way to write a maintainable web scraping app?

I wrote a perl script a while ago which logged into my online banking and emailed me my balance and a mini-statement every day. I found it very useful for keeping track of my finances. The only problem is that I wrote it just using perl and curl and it was quite complicated and hard to maintain. After a few instances of my bank changi...

How can I mark Perl code as deprecated?

In my project I'm currently preparing a step-by-step move from legacy code to new, properly-designed and tested modules. Since not every fellow programmer follows closely what I do, I would like to emit warnings when old code is used. I would also strongly prefer being able to output recommendations on how to port old code. I've found t...

Where can I find object-oriented Perl tutorials?

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I'm reading these now, but what else is out there? Note: I've made this community wiki to attempt to produce something better than Google, which appears to have mediocre tutorials that are more about o...

Why does my Perl script to decompress files slower when I use threads?

So I'm running perl 5.10 on a core 2 duo macbook pro compiled with threading support: usethreads=define, useithreads=define. I've got a simple script to read 4 gzipped files containing aroud 750000 lines each. I'm using Compress::Zlib to do the uncompressing and reading of the files. I've got 2 implementations the only difference betw...

How do I use a Perl CGI locally without using curl and apache2?

I would like to submit a form to a CGI script localy (w3c-markup-validator), but it is too slow using curl and apache, I want to use this CGI script more than 5,000 times in an another script. and currently it takes more than one hour. What should I do to give the form directly to the CGI script (I upload a file with curl)? edit: It se...

Issues instaling MIME::Lite via CPAN on Mac OS X

I am trying to install MIME::Lite using CPAN via Mac OS X Leopard and CPAN just keeps reporting back the following message: cpan shell -- CPAN exploration and modules installation (v1.9304) ReadLine support enabled cpan[1]> install MIME-Lite CPAN: Storable loaded ok (v2.21) Going to read /private/var/root/Library/Application Suppo...

Perl Moose Method Modifiers: Call 'around' before 'before' and 'after'

I'm using Moose and I need to wrap method calls in my project. It's important that my wrapping code be the most outer modifier. What I've done so far is put my method modifiers in a Moose Role and then applied that role at the end of my class like this: use Moose::Util; Moose::Util::apply_all_roles(__PACKAGE__->meta, ('App:Roles::Custom...

How can I modify the Smith-Waterman algorithm using substitution matrix to align proteins in Perl?

How can I modify the Smith-Waterman algorithm using a substitution matrix to align proteins in Perl? [citations needed] ...

Object-Oriented Perl constructor syntax

I'm a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I don't get what this line does at all, but I always see it. Do I need it? my $type = shift; #I'm turning the array of inputs into a has...

How can I make XML::Simple's output more human friendly?

I am using the XML::Simple module to parse an XML file. When I run the following script then I do not get data in human readable form and so it is difficult to see the output of the parsed XML file. Code: #!usr/bin/perl -w use XML::Simple; my $ref = XMLin('SampleXML.xml'); use Data::Dumper; print Dumper($ref); ...

String corruption and nonprintable characters using XML::Twig in Win32 Perl

This is a really weird problem. It's taken me practically all day to whittle it down to a small executable script that demonstrates the problem fully. Problem Summary: I'm using XML::Twig to pull a data snippet from an XML file, then I'm sticking that data snippet into the middle of another piece of data, let's call it parent data. ...

perl: export symbols from module that has > 1 package

module foo/bar.pm package foo::bar; stuff stuff package foo::wizzy; require Exporter; our @ISA=qw(Exporter); our @EXPORT=qw(x); use constant { x=>1 }; a consumer that goes use Foo::bar; does not get the foo::wizzy::x export I know I can make it 2 separate modules, but still I should be able to make this work - shouldnt I ...

Implementing cross-thread/process queues in Perl

What is the most efficient way of implementing queues to be read by another thread/process? I'm thinking of using a basic MySQL table with polling on sleep. This sounds to be the most scalable (it doesn't even have to be on the same server) but might potentially result in too many queries to the DB. ...

Win32:Process SetProcessAffinityMask crashes my Perl

I have a Perl script running that acts like a service, one of the things I do with it is use it to spawn other processes. Some of these processes are executables and some are perl scripts. At times I want to set the processor affinity on some these processes. I use SetProcessAffinityMask to do this, for the executables everything wo...