There are two versions of ePerl:

The former is a C wrapper around a perl module. The latter is written entirely in perl.

I was using Ralf S. Engelschall's version until now, because it is in Debian repositories. However, I wanted to return an HTTP 500 code upon error, so that Google would't index errors (as it currently does). It is hard-coded in the C code. Rather than recompiling, I tried the newer version from MarginalHacks. The error code is hard-coded as well, but it is in Perl, so easier to rewrite and to link with my standard error code.

I had to modify my shebangs (#!/usr/bin/eperl.pl --mode=CGI is fine), and also to correct an error in eperl.pl by adding


inside the

if ($opt{'mode'} ne "f") {

block (that is, between lines 220 and 224), because we don't want to use the HTTP path passed as argument in CGI mode, but rather the script file name.

Unfortunately, I quickly noted that this new ePerl looses STDIN data. That means, no POST data available in the script: and I use that for comments and contact. There is a -t argument, but it had no effect for me. I'll stick to the old ePerl for the moment, and try to make sure my code runs fine, but I'll need to have a closer look into what happens exactly with input sooner or later.

Xavier Robin
Publié le dimanche 13 juin 2010 à 18:32 CEST
Lien permanent : /blog/2010/06/13/eperl
Tags : Mon site web Programmation
Commentaires : 0

Tags cloud

There are several CPAN modules to generate tag clouds. To cite only 3 of them:

I just added tags cloud on this site (look the new home page!) with Data::CloudWeights. HTML::TagCloud generate ugly HTML and CSS that cannot be modified. HTML::TagClouder is marked as *WARNING* Alpha software! I mean it! Not for me, thanks!

Data::CloudWeights is far the most flexible. It generates an arrayref of hashes from which you can pick size, occurences, colors and so on. I use the following subroutine to generate the cloud with a very simple and standard code:

use Data::CloudWeights;
sub tag_cloud {
	my @tags = @_;
	my $cloud = Data::CloudWeights->new;
	for my $tag (@tags) {
		# The followin line is a bit more complicated than shown here
		# $tag is a DBIx::Class entry with more columns than displayed here
		$cloud->add($tag->tag, scalar  $tag->links, "/tag/" . $tag->tag);
	my $cloud_html = "";
	foreach my $tag (@{$cloud->formation}) {
		$cloud_html .= '<a href="' . $tag->{'value'} .
			'" style="font-size: ' . $tag->{'size'} . 'em">';
		$cloud_html .= $tag->{'tag'};
		$cloud_html .= '</a>';
	return $cloud_html;

Xavier Robin
Publié le dimanche 13 juin 2010 à 19:34 CEST
Lien permanent : /blog/2010/06/13/tags-cloud
Tags : Mon site web Programmation
Commentaires : 0

Switch to English



Bruit de fond Hobbys Humour Informatique Internet Livres Logiciels Moi Mon site web Mozilla Photo Politique Programmation Scolaire Ubuntu pROC

Billets récents