Mikhail T. - 2013-06-26

The attached patch works for me, but may not be the most elegant solution...

I don't really know perl very well.