in reply to I don't understand string versus numeric context

The first warning is simple. sprintf is a function that returns a formatted string. Yet you simple discarded that string. That makes no sense, so you got a warning. Perhaps you wanted printf?

"Numerical context" is a fancy way of saying the argument needs to be a number, and it will be coerced into one if necessary. It's usually very obvious when a number is required. For example, the arguments of addition must be numbers, and so does the argument for %u. Unfortunately, ^R doesn't look anything like a number, so a warning is issued ("isn't a number") and it's treated as zero. You seem to want the character's ordinal value.

printf('%u', ord($foo));

Perhaps you're from a C background where everything is a number. In Perl, it's more like everything is a string.

# C Perl # ---- ---- printf('%u', 4); # 4 4 printf('%u', '4'); # 52 4 printf('%u', 0x12); # 18 18 printf('%u', '\x12'); # 18 0* * - warns "isn't numeric"