News items for tag perl - Koos van den Hout

2009-08-24 (#) 1 year ago
More than one visitor of my homepage saw an intricate XML parsing error and not the page you all want to see. I never saw the problem myself but my best guess sofar is that the twitter rss feed was malformed, because that is the only XML parsing happening for the page. I fetch the twitter feed automatically every 6 hours, but sometimes twitter is a bit overloaded and probably gives an internal error page (the famous fail whale) and not the valid rss feed.

Solution: Fetch the file to a temporary file, run the parser on it and when the parser does not fail, copy it to where the webserver reads it:

#!/bin/sh

wget -O wwwdata/twitter.rss.pre -o /dev/null http://twitter.com/statuses/user_timeline/19301166.rss

perl -MXML::RSS -e 'my $rss=new XML::RSS; $rss->parsefile("wwwdata/twitter.rss.pre");'

if [ "$?" = "0" ]; then
	cp wwwdata/twitter.rss.pre wwwdata/twitter.rss
fi
Tags: , , ,
2009-06-12 (#) 1 year ago
Wat perl code om met Chipcard::PCSC het saldo en de laatste 5 transacties van een chipknip uit te lezen. Altijd handig als je toevallig een laptop met chipcard slot hebt. Het leuke is dat je ook kan zien wat het eigen nummer was van de chipautomaat waar je de transactie deed (SAM_ID) en het volgnummer (SAM_STAN) waarmee je kan zien waar je chipknip geweest is en kan zien hoeveel transacties automaten te verwerken krijgen. Perl code om een chipknip saldo te lezen en de laatste transacties.
Tags: , ,
2009-03-28 (#) 1 year ago
I noticed a few malformed characters in the RSS feed of my homepage that weren't there in the original database entries and showed ok in the web version. Again, utf-8 problems showing, although all data (postgres - script - xml - browser) should be utf-8. Lots of testing and searching, finally I found The Perl UTF-8 and utf8 Encoding Mess by Jeremy Zawodny. He is right: it is a mess. And the post itself demonstrates it by being filled with � characters.
So to make sure everything in the RSS generating process understand that what comes out of PostgreSQL is valid utf-8 and should be imported in the XML::RSS module as the same valid utf-8, I need to recode it to utf-8. Uh.. ok. The bit of code:
        my $body = Encode::decode('UTF-8', $row[1]);
And now I can use ÜTF-8 çħáräćtërs!
Tags: , ,
2008-03-20 (#) 2 years ago
A new version of my homepage, rewritten in perl because PHP was starting to irritate me. More database-driven in the background which allows me to add things like the tags. And a minor change in the colour scheme because someone remarked that the black-on-cyan was hard to read for people above a certain age.
Tags: , ,
2008-03-13 (#) 2 years ago
One of the little irritations at work was trying to find out what the exact error was of the printer when the helpdesk ticket just says 'printer problems'. Since HP laserjets will divulge everything via SNMP, I thought the complete information must be available. It is, and I gobbled together a perl script for our noc webserver. Public version in the perl noc stuff page.
Tags: , ,
2008-01-02 (#) 2 years ago
My first CPAN upload. I uploaded Geo::METAR 1.15 to CPAN just now. Time to find out if I did stuff right.
Tags: , , , ,
2004-10-11 (#) 5 years ago
Played a bit with Geo::METAR so now my Webcam knows the almost-local weather and pastes it into the image.
Tags: , ,

IPv6 ready
Koos van den Hout, E-mail koos+web@kzdoos.xs4all.nl. PGP key DSS/1024 0xF0D7C263 RSS
Other webprojects: Camp Wireless, wireless Internet access at campsites, The Virtual Bookcase, book reviews, Weather maps