perl

How do I fork properly with mod_perl2?

Hi there. I'm having trouble forking a long-running process from some code running under mod_perl2. Everything works for the most part, but it seems that the forked process is holding open handles to Apache's logfiles - this means Apache won't restart while the process is running (I get a 'failed to open logfiles' message). Here's the...

How do I combine .EXE commands in Perl?

Hi I have a set of .EXE commands. How do I get all those commands run in Perl as a single file? Whats the process to call the .EXE files in Perl? ...

How to trace and profile all low level calls (c libraries) being used by a mod_perl or a mod_php application?

I've seen once on a site, a call graph digging into the most low level libraries of a web request initiated by a PHP appplication with call timings and summary. Seems to me that this is a great way to spot the reason of bottlenecks that aren't obvious while profiling PHP-only code. Something like strace does but with far more detail. ...

Does Perl have an enumeration type?

Does Perl have an enumeration type that adheres to best practices, or maybe more importantly, does it need one? The project I am working one uses strings all over the place to denote things that would typically use an Enum in a language like C#. For example, we have a set of phone numbers in an array of hashes, each associated with a p...

How do I get started with Perl 6?

I'd like to get your opinion on How to get started with Perl 6? Shall one use Rakudo which is being build on Parrot or still better go with the Pugs implementation? If Rakudo, what is the best way to install it? The monthly releases of Parrot, right from the SVN of Parrot, other? ...

Does Perl monkey-patching allow you to see the patched package's scope?

I'm monkey patching a package using a technique given at the beginning of "How can I monkey-patch an instance method in Perl?". The problem that I'm running into is that the original subroutine used a package-level my variable which the patched subroutine appears not to have access to, either by full path specification or implicit use. ...

Where is flock() for Perl on Windows?

I have a Perl script that I'd like to run on Windows, using either Strawberry Perl or ActivePerl; I don't care which. This script however, uses flock() calls, which does not seem to be included in either of those versions of Perl. Can anyone help a Perl n00b get this up and running easily? ...

How can I assemble SQL with object-oriented Perl?

I'm currently in charge of a process that seems to be very intimate with the database. My program/script/framework's goal is to make uniformity out of disparate data sources. Using a form of dependency injection, my process at a very high level works fine. The implementation of each data source type is hidden from the highest level busin...

How can I match double-quoted strings with escaped double-quote characters?

I need a Perl regular expression to match a string. I'm assuming only double-quoted strings, that a \" is a literal quote character and NOT the end of the string, and that a \ is a literal backslash character and should not escape a quote character. If it's not clear, some examples: "\"" # string is 1 character long, contains dobule ...

As a PHP developer thinking of making Perl a secondary strong suit, what do I need to know?

I consider myself quite fluent in PHP and am rather familiar with nearly all of the important aspects and uses, as well as its pratfalls. This in mind, I think the major problem in taking on Perl is going to be with the syntax. Aside from this (a minor hindrance, really, as I'm rather sold on the fact that Perl's is far more readable), w...

How can I validate an image file in Perl?

How would I validate that a jpg file is a valid image file. We are having files written to a directory using FTP, but we seem to be picking up the file before it has finished writing it, creating invalid images. I need to be able to identify when it is no longer being written to. Any ideas? ...

How can I tell when another process has stopped writing to a file in Perl?

I have a system which is writing files to a folder using FTP. I need to copy those files, but only when they FTP system has finished. How do I tell when the first process has finished writing. ...

How can I catch the output from a carp in Perl?

I am writing a Perl module, and I am using carp to throw a non-fatal warning back to the calling program. The carp warning works fine - I am checking if an input parameter meets a certain condition - if it does not meet the condition, a warning is sent with carp and the module continues on using a default for the parameter instead of th...

How do I convert a binary string to a number in Perl?

How can I convert the binary string $x_bin="0001001100101" to its numeric value $x_num=613 in Perl? ...

Does it make sense to rewrite Perl and shell scripts in java?

I have a bunch of scripts - some in perl and some in bash - which are used for: Creating a database (tables, indexes, constraints, views) Parsing spreadsheets and loading the data into the database Getting info about a bunch of files and loading that into the database. These scripts are used in conjunction with a much larger applicat...

How can I stretch or resize an image using Perl?

Hi, How to stretch or resize an image (Of any Format) using a Perl script? Could any one suggest please. Tnx in advance. ...

Is $_ more efficient than a named variable in Perl's foreach?

I am quite new in Perl and I woud like to know which of the following loops is more efficient: my @numbers = (1,3,5,7,9); foreach my $current (@numbers){ print "$current\n"; } or my @numbers = (1,3,5,7,9); foreach (@numbers){ print "$_\n"; } I want to know this in order to know if the use of $_ is more efficient because is...

What's the best XML parser for Perl?

I have tried many of the Perl XML Parsers. I was quite interested in the Sablotron Parser, but it is such a pain to install on a Windows box. Currently I have started using XML::LibXML and XML::LibXSLT both of which seem to do everything I need. They seem to be quite standard as well. Are there any better XML Parsers to use than th...

How do you read the system time and date in Perl?

I need to read the system clock (time and date) and display it in a human-readable format in Perl. Currently, I'm using the following method (which I found here): #!/usr/local/bin/perl @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); ($second, $minute, $hour, $dayOfMonth, $...

How can I replace all the HTML-encoded accents in Perl?

I have the following situation: There is a tool that gets an XSLT from a web interface and embeds the XSLT in an XML file (Someone should have been fired). "Unfortunately" I work in a French speaking country and therefore the XSLT has a number of words with accents. When the XSLT is embedded in the XML, the tool converts all the accents...