perl

Where can I find a concise guide to converting an existing CPAN module to use Dist::Zilla?

I have read, at various times, both the documentation and a number of blog posts on Dist::Zilla. I have never felt confidence in my understanding of it. In response to another question, @Ether raised the possibility of converting Crypt-SSLeay to use Dist::Zilla. So, where can I find a concise guide showing me how to convert an existing...

How can I fetch the same URL with different query string with Perl's LWP::UserAgent?

I looked up articles about using LWP however I am still lost! On this site we find a list of many schools; see the overview-page and follow some of the links and get some result pages: I want to parse the sites using LWP::UserAgent and for the parsing : want to use either HTML::TreeBuilder::XPath or HTML::TokeParser At the moment I am ...

How can I execute a Perl script inside C++ console application?

I am new to C++ programming :). I was wondering what would be the best and easiest approach for this problem. I have a C++ console application and a Perl script. Both of them are to be integrated. To be more specific need to write perl perlscript.pl arg1 in a cmd prompt (to execute the Perl script). perform few actions in C++ console a...

syb_nsql vs execute calls in Perl

I am trying to query Sybase database using DBD::Sybase. Can someone please clarify what is the difference between using syb_nsql vs prepare(...) - execute(..) calls? ...

How can I use a Perl module from Python?

There exists a Perl module that provides the perfect functionality for my Python app. Is there any way for me to utilize it? (it is complicated, it would take me a month to port it) I don't want to have to spawn a subprocess for every usage, as I need it several hundred thousand times (it is a specific type of data parser). Thanks fo...

What's the best way to apply many Perl regular expression tests?

I have a Perl module that matches text against a list of hundreds of regexes; currently I am just or'ing them: if ( /?:re1/ or ... /re200$/ ) { return "blah"; } Is there a better/faster/less resource-intensive way to do this? Perhaps a useful module exists, or I should store them in a hash, etc. ...

nginx and Perl: FastCGI vs reverse proxy (PSGI/Starman)

A very popular choice for running Perl web applications these days seems to be behind a nginx webserver proxying requests to either a FastCGI daemon or a PSGI enabled webserver (e.g. Starman). There have been lots of question as to why one would do this in general (e.g. http://stackoverflow.com/questions/2939393/why-use-nginx-with-catal...

How can I overload Moose constructors?

Sorry for the Java jargon, but how can I overload Moose constructors? Suppose I'm representing a segment. I can either take a start point and and point, or a start point and length, or end point and length. How can I allow for such alternative construction methods? ...

XML::Simple encoding problem

Hi, I have an xml-file I want to parse: <?xml version="1.0" encoding="UTF-8" ?> <tag>û</tag> It's perfectly parsed by firefox. But XML::Simple corrupts some data. I have a perl-program like this: my $content = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; $content .= "<tag>\x{c3}\x{bb}</tag>\n"; print "input:\n$content\n"; my $...

How can I run my Perl script only if it wasn't loaded with require?

I have a Perl script. If it was called direct from the command line, I want to run sub main. If it was called using require, I want to do nothing and wait for the caller script to call sub job at it's leisure. ...

Find and replace without storing variable

Is there a way to do this in one line? my $b = &fetch(); $b =~ s/find/replace/g; &job($b) ...

Why is my Perl loop off by one at the end?

I have this program which does not work as expected. Help me. I want to print a row heading. If input is 4, I want 1|2|3|4 to be output. It does not work as all, if I hard-code $count value it works partially but the last number is missing. sub printC { my $count = @_; # count = 4 # works partially only prints 1|2|3 ...

Why is my Perl regex so slow?

I have the following regex: my $scores_compiled_regex = qr{^0 \s+ (\p{Alpha}+\d*) \s+ (\d+ \s* \p{Alpha}*) ...

How can I install a newer Perl without damaging the system install?

I have seen plenty of people mention some of the cool new features in Perl >= 5.12 but my preferred flavor of Linux Ubuntu only comes with 5.10.1. I have no fear of PPAs and I know how to google (unless someone finds me something, then I'll feel sheepish). I cannot find someone that provides a Perl PPA; I thought there was a PPA for ev...

How do I use the object I get from Perl's Image::MetaData::JPEG?

I am using the Image::MetaData::JPEG module to read an image's header information. I have the following: my @files = </dir/*jpg>; for (@files) { my $image = new Image::MetaData::JPEG( $_ ) or die $!; print $image . "\n"; } This returns "Image::MetaData::JPEG=HASH(0x189b218)". I've read through the module but how do I actually ge...

How can I modify a Moose attribute handle?

Following phaylon's answer to "How can I flexibly add data to Moose objects?", suppose I have the following Moose attribute: has custom_fields => ( traits => [qw( Hash )], isa => 'HashRef', builder => '_build_custom_fields', handles => { custom_field => 'accessor', has_custom_fiel...

Is it possible to write one-liners in Python?

I was going through the code golf question here on Stack overflow and saw many perl one liner solution. My question is: Is something like that possible in Python? ...

What is the best way to handle exceptions in perl?

I've noticed that Exception.pm and Error.pm don't seem to be extensively used in the perl community. Is that due to the large footprint of eval for exception handling? Also perl programs appear to have a much more lenient policy regarding exception handling in general. Is there a compelling reason for this? In any event what would be...

How do I access the HTTP Header of request in a CGI script?

I've used Perl a bit for small applications and test code, but I'm new to networking and CGI. I get how to make the header of a request (using CGI.pm and printing the results of the header() function), but haven't been able to find any info on how to access the headers being sent to my CGI script. Could someone point me in the right dir...

What Perl regex can match the contiguous subset of digits 12345?

I would like a Perl regex that matches any contiguous subset of the string '12345'. I'm probably just having a brain-freeze, but this is my test code and current best regex. I can see how to brute-force the situation by adding alternatives, but I'm wondering which elegant alternative I'm missing. [I don't specifically need captures fo...