divisionbyzero

question . authority

Vacation and PHP

I took a much needed vacation the latter part of last week. Prior to that, I was helping a few coworkers with getting PHP Web Applications developed on Fedora Core 5 to run on CentOS 5 with upgraded PHP, Apache, and libraries. Every time I work with PHP, it gives me serious perspective as to why the Modern Perl / Enlightened Perl / perl5i Projects are incredibly important. The Matt’s Scripts Perl era needs to die. This stagnant snapshot has poisoned Perl’s reputation for too long.

The main difference between Perl and PHP, is writing maintainable, intelligent Perl is only slightly more work at first than writing horrible Matt’s Scripts style Perl. With PHP, writing decent PHP is possible, but it’s incredibly difficult. The majority of the PHP I’ve come across is code written by a web developer with no programming experience and the language design and direction accommodate that demographic. PHP’s language design gets in the way of writing sane, maintainable code. It’s not impossible, but you have to really, really want it.

When you write good Perl, the programming experience becomes easier, and more fun.

I’m trying to get back to my programming projects, and thus back to writing more on Perl. For now, understand that if you think Perl and PHP are the same beast, you’re wrong. I’ve been paid to develop both for periods of years. Perl is much more eloquent, evolutionary, and intelligent.

Using POE to hook syslog-ng

Being able to do analysis, sorting, or database storage of syslog messages is incredibly useful. There are tons of solutions on the market to do just that. If you’re working on a system developed in house that you’d like to incorporate syslog messages into, then it may be easier to hook directly into the syslog stream than to introduce another piece of software into the environment which needs to be glued.

Syslog-ng facilitates easy integration with Perl binaries as the Perl program is spawned once during the daemon start up and a handle to that program’s STDIN is maintained for dispatching of messages. Using POE, we can turn this into an event driven model, making additional complexity simple.

In this example, we’ll create a POE Master session that receives all of the syslog-ng input from STDIN. Using off the shelf components, we’ll run a TCP Server on port 9514 that will allow clients to connect and subscribe to feeds based on the “program” name of the message being dispatched.
Read the rest of this entry »