Peter Blair

Perl decorators

One of the great things that I enjoy about Python, are the decorators. I try to use them whenever possible in my Python projects, and sorely miss them at times in my Perl projects.

Last week I was thinking of profiling my Perl applications remotely and was pining for decorators. With Perl 5.10 lacking decorators, I created a Perl filter package to create “decorator like” syntax-sugar to support the emission of certain metrics like:

– Label assigned to function
– Time elapsed
– Return val

This triplet is then sent via UDP to some listener that can do with it as it may. Aggregate it, store it in a noSQL store, whatever.


Categorised as: Perl


2 Comments

  1. Jacob Rideout says:

    Peter, have you played with perl attributes?

  2. admin says:

    Damnit, that’s EXACTLY what I was looking for. I hate re-inventing the wheel.

Get Adobe Flash player