perl

What's the best system for installing a Perl web app?

It seems that most of the installers for Perl are centered around installing Perl modules, not applications. Things like ExtUtils::MakeMaker and Module::Build are very well suited for modules, but require some additional work for Web Apps. Ideally it would be nice to be able to do the following after checking out the source from the re...

Searching/reading another file from awk based on current file's contents, is it possible?

I'm processing a huge file with (GNU) awk, (other available tools are: Linux shell tools, some old (>5.0) version of Perl, but can't install modules). My problem: if some field1, field2, field3 contain X, Y, Z I must search for a file in another directory which contains field4, and field5 on one line, and insert some data from the found...

What's the best approach to migrate a CGI to a Framework?

Hi, i have a big web application running in perl CGI. It's running ok, it's well written, but as it was done in the past, all the html are defined hardcoded in the CGI calls, so as you could imagine, it's hard to mantain, improve and etc. So now i would like to start to add some templating and integrate with a framework (catalyst or CGI:...

Perl Best Practices: What shouldn't I use?

For those of us who are familiar with Damian Conway's Perl Best Practices, it may be the case that you're applying it somewhat selectively. Which of the Best Practices do you elect not to follow, if any, and for what reasons? Or do you always apply as many of the best practices as possible? For example, the following Best Practices I'...

Python v. Perl

Okay, so I'm finally making the jump into scripting languages and I have decided to focus on either Python or Perl. The problem is: I don't know which to cut my teeth on. Most of my programming experience is in C, Java, and C++. There's no specific task I would be learning Python/Perl for, other that possibly applying it to my dev work ...

Is there some way to make variables like $a and $b in regard to strict?

In light of Michael Carman's comment, I have decided to rewrite the question. Note that 11 comments appear before this edit, and give credence to Michael's observation that I did not write the question in a way that made it clear what I was asking. Question: What is the standard--or cleanest way--to fake the special status that $a and ...

How can I convert a number to its multiple form in Perl?

Hello everybody, Do you know an easy and straight-forward method/sub/module which allows me to convert a number (say 1234567.89) to an easily readable form - something like 1.23M? Right now I can do this by making several comparisons, but I'm not happy with my method: if($bytes > 1000000000){ $bytes = ( sprintf( "%0.2f", $bytes/10...

Why do you need $ when accessing array and hash elements in Perl?

Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array @myarray and a hash %myhash, why do you need to do: $x = $myarray[1]; $y = $myhash{'foo'}; instead of just doing : ...

How can I create XML from Perl?

Hello I need to create XML in Perl. From what I read, XML::LibXML is great for parsing and using XML that comes from somewhere else. Does anyone have any suggestions for an XML Writer? Is XML::Writer still maintained? Does anyone like/use it? In addition to feature-completeness, I am interested an easy-to-use syntax, so please desc...

What does `$hash{$key} |= {}` do in Perl?

I was wrestling with some Perl that uses hash references. In the end it turned out that my problem was the line: $myhash{$key} |= {}; That is, "assign $myhash{$key} a reference to an empty hash, unless it already has a value". Dereferencing this and trying to use it as a hash reference, however, resulted in interpreter errors about ...

Ruby / Perl / Python / etc. tutorial site - only code

A few weeks ago I've run into a site that had tutorials for many languages including Perl, Ruby, Python. The concept was that it basically showed you the code itself of the given language and taught you like that, so the whole tutorial was a great amount of code and some comments in it. The only problem is that I forgot to bookmark it an...

Perl: Grabbing the nth and mth delimited words from each line in a file

Because of the more tedious way of adding hosts to be monitored in Nagios (it requires defining a host object, as opposed to the previous program which only required the IP and hostname), I figured it'd be best to automate this, and it'd be a great time to learn Perl, because all I know at the moment is C/C++ and Java. The file I read...

What is the best XSLT engine for Perl?

I would like to know what of the many XSLT engines out there works well with Perl. I will use Apache (2.0) and Perl, and I want to obtain PDFs and XHTMLs. I'm new to this kind of projects so any comment or suggestion will be welcome. Thanks. Doing a simple search on Google I found a lot and I suppose that there are to many more. ...

Why can't I use Template Toolkit?

I am trying to use TemplateToolkit instead of good ole' variable interpolation and my server is giving me a lot of grief. Here are the errors I am getting: *** 'D:\Inetpub\gic\source\extjs_source.plx' error message at: 2008/09/30 15:27:37 failed to create context: failed to create context: failed to load Template/Stash/XS.pm: Couldn't ...

What's wrong with my SOAP call to OnTime from my SVN post-commit hook?

My Subversion repository is on a Linux server and my OnTime 2007 system is on a Windows 2003 server. I have a post-commit hook script that launches two Perl scripts. One sends an emailworks great. The other is supposed to write the details from the SVN commit to the Notes section of the OnTime tracking system. I have lots of debuggin...

Traversing a multi-dimensional hash in Perl

If you have a hash (or reference to a hash) in perl with many dimensions and you want to iterate across all values, what's the best way to do it. In other words, if we have $f->{$x}{$y}, I want something like foreach ($x, $y) (deep_keys %{$f}) { } instead of foreach $x (keys %f) { foreach $y (keys %{$f->{$x}) { } ...

Java development in a Perl shop: How to select the right tool?

My group is a Perl shop in an organization that is very heterogenous. Although we support the odd Java, PHP, or Python installation, we're using Perl for nearly all of our web applications and systems/data marshalling tasks. All of our boxes are Linux, although we interface with IIS systems as well. We're coming under some pressure fr...

How does a Perl socket resolve hostnames under Linux?

I have a (from what I can tell) perfectly working Linux setup (Ubuntu 8.04) where all tools (nslookup, curl, wget, firefox, etc) are able to resolve addresses. Yet, the following code fails: $s = new IO::Socket::INET( PeerAddr => 'stackoverflow.com', PeerPort => 80, Proto => 'tcp', ); die "Error: $!\n" unless $s; I verifi...

Emulation of lex like functionality in Perl or Python.

Here's the deal. Is there a way to have strings tokenized in a line based on multiple regexes? One example: I have to get all href tags, their corresponding text and some other text based on a different regex. So I have 3 expressions and would like to tokenize the line and extract tokens of text matching every expression. I have actua...

How can I create a web page that shows aggregate data from Sawtooth surveys?

I'm guessing this won't apply to 99.99% of anyone that sees this. I've been doing some Sawtooth survey programming at work and I've been needing to create a webpage that shows some aggregate data from the completed surveys. I was just wondering if anyone else has done this using the flat files that Sawtooth generates and how you went abo...