Thanks - that makes sense. Effectively my problem then is that the callers of my subroutine are passing in things other than bytes when they shouldn't be. As the code that calls my subroutine was written by me as well I shall have to give myself a good talking to!