perl

Perl Challenge - Directory Iterator

You sometimes hear it said about Perl that there might be 6 different ways to approach the same problem. Good Perl developers usually have well-reasoned insights for making choices between the various possible methods of implementation. So an example Perl problem: A simple script which recursively iterates through a directory structur...

Hidden features of Perl?

What are some really useful but esoteric language features in Perl that you've actually been able to employ to do useful work? Guidelines: Try to limit answers to the Perl core and not CPAN Please give an example and a short description Hidden Features also found in other languages' Hidden Features: (These are all from Corion's a...

How can I handle HTTP file uploads?

How would I write a Perl CGI script that receives a file via a HTTP post and saves that to the file system? ...

How can I split a pipe-separated string in a list?

Here at work we are working on a newsletter system that our clients can use. As an intern one of my jobs is to help with the smaller pieces of the puzzle. In this case what I need to do is scan the logs of the email server for bounced messages and add the emails and the reason the email bounced to a "bad email database". The bad emails ...

How can I add internationalization to my Perl script?

Hi there, I'm looking at introducing multi-lingual support to a mature CGI application written in Perl. I had originally considered rolling my own solution using a Perl hash (stored on disk) for translation files but then I came across a CPAN module which appears to do just what I want (i18n). Does anyone have any experience with in...

Why is my Perl regex using so much memory?

I'm running a regular expression against a large scalar. Though this match isn't capturing anything, my process grows by 30M after this match: # A if (${$c} =~ m/\G<<\s*/cgs) { #B ... } $c is a reference to a pretty big scalar (around 21M), but I've verified that pos(${$c}) is in the right place and the expression matches at ...

Perl - Common gotchas?

The question on Hidden features of Perl yielded at least one response that could be regarded as either a feature or a mis-feature. It seemed logical to follow up with this question: what are common non-obvious mistakes in Perl? Things that seem like they ought to work, but don't. I won't give guidelines as to how to structure answers,...

What's the best way to tell if your perl's running on -e?

The question is not how to tell in a oneliner. If you're writing the code in a one-liner, you know you are. But how does a module, included by -MMy::Module::Name know that it all started from a oneliner. This is mine. It's non-portable though and relies on UNIX standard commands (although, it can be made portable more or less.) my $pr...

Where are some good resources for learning the new features of Perl 5.10?

Hi! I didn't realize until recently that Perl 5.10 had significant new features and I was wondering if anyone could give me some good resources for learning about those. I searched for them on Google and all I found was some slides and a quick overview. Some of the features (to me at least) would be nice if they had more explanation. ...

What features of Perl 6 are you the most excited about?

Perl 6 has really shaped up in terms of which features we can expect to see implemented in the final language, when it comes. Some of them are already available through Perl 6 modules for Perl 5 from CPAN. So which features are most compelling, exciting, nifty, eagerly awaited, etc.? Please try to limit yourself to one feature per ans...

Sorting music

So over the years, I've bought music off iTunes, Urge, and Rhapsody and all these files are lying mixed with my non-DRM'd MP3 files that I've ripped off my CDs. Now some of these files have licenses that have expired, and some of them have valid licenses. I want to sort my music by various DRM/license restrictions that they have on them...

How to find and tail the Oracle alert log

When you take your first look at an Oracle database, one of the first questions is often "where's the alert log?". Grid Control can tell you, but its often not available in the environment. I posted some bash and Perl scripts to find and tail the alert log on my blog some time back, and I'm surprised to see that post still getting lots ...

How can I extract a line or row?

How can I extract the whole line in a row, for example, row 3. These data are saved in my text editor in linux. Here's my data: 1,julz,kath,shiela,angel 2,may,ann,janice,aika 3,christal,justine,kim 4,kris,allan,jc,mine I want output like: 3,christal,justine,kim ...

How do I elegantly print the date in RFC822 format in Perl?

How can I elegantly print the date in RFC822 format in Perl? ...

What are the best resources to start learning Perl?

I want to start learning Perl from scratch and I need to find some good tutorials and books to begin with. I found this tutorial very helpful and I'm wondering if you guys know of some more useful resources to help me learn more about this language. ...

Parsing and generating Microsoft Office 2007 files (.docx, .xlsx, .pptx)

Hello, I have a web project where I must import text and images from a user-supplied document, and one of the possible formats is Microsoft Office 2007. There's also a need to generate documents in this format. The server runs CentOS 5.2 and has PHP/Perl/Python installed. I can execute local binaries and shell scripts if I must. We use...

What is the best way to delete a value from an array in Perl ?

The array has lots of data and I need to delete two elements. Below is the code snippet I am using my @array = (1,2,3,4,5,5,6,5,4,9); my $element_omitted = 5; @array = grep { $_ != $element_omitted } @array; ...

What's the deal with all the different Perl 6 equality operators? (==, ===, eq, eqv, ~~, =:=, ...)

Perl 6 seems to have an explosion of equality operators. What is =:=? What's the difference between leg and cmp? Or eqv and ===? Does anyone have a good summary? ...

How can I automate HTML-to-PDF conversions?

I've been using htmldoc for a while, but I've run into some fairly serious limitations. I need the end solution to work on a Linux box. I'll be calling this library/utility/application from a Perl app, so any Perl interfaces would be a bonus. ...

How can I speed up my Perl program?

This is really two questions, but they are so similar, and to keep it simple, I figured I'd just roll them together: Firstly: Given an established Perl project, what are some decent ways to speed it up beyond just plain in-code optimization? Secondly: When writing a program from scratch in Perl, what are some good ways to greatly impr...