mt plugins and perl stuff

gav on 2003-04-09T17:55:33

I've fixed a long outstanding bug* in my InterceptVector MT Plugin. It took me forever to fix it because I was being really dumb. I kept getting an error with the <$MTWeatherHumidity$> tag that I just couldn't figure out. The problem was that on both my server and my laptop I have this plugin and my Weather::Underground plugin installed and they were both trying to create a tag called the same thing. In other news Weather::Underground is broken due to slight changes to the HTML it is scraping.

* Thanks to Vek

I've never really made much use of $/ until recently. I've really only ever set it to undef to slurp files but recently I've found some cunning uses for the input record separator.

For example a quick hack to convert the results from mysqldump into a CSV file to import into Access:

local $/ = ');';
while (<$in>) {
    if (my ($line) = /INSERT INTO \w+ VALUES \((.+?)\);$/s) { 
        $line =~ s/NULL/''/g;
        print {$out} $line, "\n";            
    }
}

I had a huge XML document that I wanted to split into record based files (as it was broken XML):

local $/ = '';
while (my $rec = <$in>) {
	# we've got a whole record
}

It's not that exciting or new but it's another tool for the toolbox.