The length definition is to return the length of characters in a string and not neccessarily the length in bytes (ie. when dealing with multibyte character strings). The locale environment variable affects how the length function views the string. In en_US.UTF-8 the length function treats each multibyte character as 1 character and returns 1 when indeed this character takes up 3 bytes. In en_US the length function treats each byte as a separate character so it returns 3. I want the latter of these results (to get the number of bytes in the string). I am trying to play around with bytes::length to do effectively the same thing regardless of locale but I still find it strange that the setlocale function doesn't work when done in the perl script.