Automatic variable highlighting in vim: the easy way

Three days ago, Ovid was nice enough to write about variable highlighting in vim. When I tried that vim script myself, I soon ran into the bug that was also found by Robin: If the cursor is above a hash, the actual use of the hash won't be matched.

So I took a look at the vimscript code and ... found that it's way too much code for my taste.

Overheard on stackoverflow

Commenter: why did you comment out use strict;?

OP: because i was getting errors and warnings because not all variables are defined as "my" or "our". it is for testing purposes only. I will uncomment that line later when the script works.


No link to protect the innocent.

Modules in core: who cares?

two-things-i-dont-like.jpeg

When I first read about the idea to remove CGI.pm from core, I was like "Yeah!". And then I thought about it and I was like "meh".

Who cares? Your typical noob that needs to be protected from the horrors of CGI.pm is not the kind of guy who builds his own perl. He is also not the kind of guy who uses an up-to-date perl. He probably has some company server running 5.8 or he might use whatever his hoster installed. Before he learns that there even is a core, he'll have a zoo of spaghetti cgi-scripts that won't work when using strictures.

But here is someone who will care about a missing CGI: the package maintainers of all the Linux distros out there. They will have to decide whether to pack CGI.pm into their main perl-package or whether to put it in its own new package. Since there are about a gazillion packages that quietly depend on CGI.pm, their most likely choice will be the former option.

So what I am trying to say is: You will not kill CGI.pm by removing it from core. But removing it from core will also not be noticed by any kind of user who doesn't know how to use a cpan client.

How to use SOAP::Transport::HTTP::Plack

I needed to port a little cgi-script that implements a simple SOAP-server to Plack. After a little searching, I came across SOAP::Transport::HTTP::Plack.

Unfortunately, the documentation of this module is ... not really helpful.

Here's my (slightly modified) cgi-script:

#!/usr/bin/perl

use SOAP::Transport::HTTP;

SOAP::Transport::HTTP::CGI
    ->dispatch_to(
        '/some/directory', 
        'Some::SOAP::Module1', 
        'Some::SOAP::Module2',
    )->handle;

Simple enough.

After some help of the awesome hobbs on IRC, here's part of my Plack psgi file:

use Plack::Builder;
use Plack::Request;
use SOAP::Transport::HTTP::Plack;

my $soap = SOAP::Transport::HTTP::Plack->new;

my $soap_app = sub {
    my $env = shift;

    return $soap
            ->dispatch_to(
                '/some/directory', 
                'Some::SOAP::Module1', 
                'Some::SOAP::Module2',
            )->handler( Plack::Request->new( $env ) );
};

return builder {
    mount 
        '/soap_test' => $soap_app;
}

And low and behold, it works!

LCLOC of the month

Here's the Least Comprehensible Line Of Code I came across this month. Took me a while to make sure it really did what I thought it did.

my @array;
# ...
@array = map {$_;} (@array, keys %{$this->{'someobject'}->get_some_hash_ref()});

Bonus points for using $this instead of $self.