perl

Why doesn't "use lib" take effect in this way?

In my app, I put all the modules in one directory , let's just call it libx. Since it's up to the user to choose where to deploy the app, I don't want to hardcode the lib path. So at the beginning of myapp.pl, I wrote the following lines of code. #! /usr/bin/perl -w use strict; my $curr_dir = $0; my $curr_lib = $curr_dir; $curr_lib =...

What are the most important features of an IDE for Perl development?

As some of you might know I am the lead developer of Padre, the Perl IDE. In the first year of its development Padre became an acceptable text editor with some extra features for Perl development. I'd like to ask the Stack Overflow community for some help in driving the project further to turn it into an exceptional IDE for Perl develop...

Error when using Class::Tangram::Generator on schemas with dates

...

Does the POSIX module in the standard Perl distribution work in Win32/64?

I was wondering whether using POSIX.pm would make my Perl code less cross platform. From reading the documentation it's not very clear how well it's supported on Win32/64 Perl implementations. Is it wise to rely use POSIX.pm if one cares about portable code? ...

How can I create a Unicode character from its bytes when they are stored in different variables in Perl?

I am trying to Convert hex representations of Unicode characters to the characters they represent. The following example works fine: #!/usr/bin/perl use Encode qw( encode decode ); binmode(STDOUT, ':encoding(utf-8)'); my $encoded = encode('utf8', "\x{e382}\x{af}"); eval { $encoded = decode('utf8', $encoded, Encode::FB_CROAK); 1 } or p...

How can I convert a number to text in Perl?

I need some code in my program which takes a number as input and converts it into corresponding text e.g. 745 to "seven hundred forty five". Now, I can write code for this, but is there any library or existing code I can use? ...

How can I link against the PostgreSQL libs when I compile Cyrus's seiveshell?

I maintain a software stack consisting of Perl and Cyrus IMAP among other things. Perl seems to be working fine and Cyrus cyradm (a perl script) works fine too. However, sieveshell will not execute and reason for asking for help here. When I run sieveshell, I get the follow output: Can't load '/usr/local/pozix/perl-5.10.0/lib/site...

Why can't I use an expression to build a class name in Perl's require?

Hi Guys, Suppose the module AAA::BBB::CCC located in ~/modules/AAA/BBB/CCC.pm, and "~/modules" is in @INC, so why the following code doesn't work and lead to compile error? $class = "AAA::BBB" ; $type = "CCC"; require $class . '::' . $type ; I try to use require AAA::BBB::CCC instead, it works . If I do need dynamically require a mo...

How can I create a page based on image size in PDF::API2?

Hi guys. I am creating a pdf from a list of image files and I was wondering if it was possible to create each page of my pdf to be the size of whatever image I am currently adding - so they all fit and none of the larger ones get cropped or whatever. Currently I'm creating pages like this: my $page = $pdf->page(); I have an object of...

What's good practice for Perl special variables?

First off, does anyone have a comprehensive list of the Perl special variables? Second, are there any tasks that are much easier using them? I always unset $/ to read in files all at once, and $| to automatically flush buffers, but I'm not sure of any others. And third, should one use the Perl special variables, or be more explicit in ...

Why is my Catalyst application slow to restart?

Hello! Each time I build a Catalyst application I come to a point where the application gets painfully slow to (re)start, the delay is about 10 seconds. Today I figured the delay is caused by the following lines: use lib '/home/zoul/opt/lib/perl/5.8'; use lib '/home/zoul/opt/share/perl/5.8'; use lib '/home/zoul/opt/lib/perl/5.8.8'; use ...

How can I make a static analysis call graph for Perl?

I am working on a moderately complex Perl program. As a part of its development, it has to go through modifications and testing. Due to certain environment constraints, running this program frequently is not an option that is easy to exercise. What I want is a static call-graph generator for Perl. It doesn't have to cover every edge ca...

Why aren't WorkDayBeg and WorkDayEnd working in Date::Manip?

I have this at the top of my personal configuration file (as well as holidays, which are being respected, so I know the file is being read...): WorkDayBeg = 08:00 WorkDayEnd = 17:00 ... and yet when I do a delta on 08:00 to 17:00 in business mode, it says 8 hours instead of 9. It is defaulting to a work day of 09:00 to 17:00. Any id...

How can I interpolate an array of alternations into a Perl regex?

Is it possible to do: @foo = getPileOfStrings(); if($text =~ /@foo(*.?)@foo/) { print "Sweet, you grabbed a $1! It lived between the foos!"; } What's going on here is I need a $text =~ /($var1|$var2|$var3)(*.?)($var1.../; I don't know how many values there are, and I don't know the values until run-time. Array interpolation into a ...

Why does my Perl regex cause an infinite loop?

I have some code that grabs the "between" of some text; specifically, between a foo $someword and the next foo $someword. However, what happens is it gets stuck at the first "between" and somehow the internal string position doesn't get incremented. The input data is a text file with newlines here and there: they are rather irrelevant,...

How can I get timestamps in Perl DBI logfiles?

I have an issue where an application is randomly dying during a DBI call. We cannot reliably reproduce this in our test or acceptance environment, so I am required to monitor it on our production system to try to figure out what is happening. I am logging all the DBI traffic via the DBI_TRACE environment variable. DBI_TRACE=3=dbi.log s...

How do I shuffle two arrays in exactly the same way in Perl?

Does anyone know how to shuffle two arrays randomly in exactly the same way in Perl? For example, say I have these two arrays: Before shuffling: array 1: 1, 2, 3, 4, 5 array 2: a, b, c, d, e After shuffling: array 1: 2, 4, 5, 3, 1 array 2: b, d, e, c, a So every element in each array is bound to its equivalent element. ...

How do I use symbolic references in Perl?

In Perl, if a variable holds the name for another variable, how do I use the first variable to visit the other one? For example, let $name = "bob"; @bob = ("jerk", "perlfan"); how should I use $name to get to know what kind of person bob is? Although I'm not quite sure, my vague memory tells me it might related to typeglob. ...

How can I open a file found by File::Find from inside the wanted function?

I have code like below. If I open the file $File::Find::name (in this case it is ./tmp/tmp.h) in my search function (called by File::Find::find), it says "cannot open the file ./tmp/tmp.h reason = No such file or directory at temp.pl line 36, line 98." If I open the file directly in another fuction function, I am able open the file. C...

How can I format a number to three decimal places with Perl?

I have a number, and need to add a decimal to it for formatting. The number is guaranteed to be between 999999 and 1000 (I have covered the other possibilities in other ways, this is the one I can't get my head around). I need to put a decimal before the last 3 digits, such as: 999.999 or 1.000 or 23.513 What kind of regex will accomp...