I actually went with the sub given on the Perl FAQ :-)

But thanks anyway.