|Do you know where your variables are?
What did you change somewhere else? I see you're not using use strict; or use warnings;, so I'd have to immediately assume that your at-a-distance change modified your unrestricted global variable $c somehow. Did you print "]$c[\n"; to see what it looked like before the sprintf call?
The reason we lexical-ize variables is to prevent possible at-a-distance modification of variables that we don't expect, which makes troubleshooting extremely difficult. It's just too easy to clobber variables in other parts of the application without any warning or notification.
I'm not saying this is what's happening, but it's my first guess if I was to troubleshoot the issue.
"the problem seems to be that perl does things behind your back"
perl only does this if you let it. By not using use strict; and use warnings;, you're running with scissors with a blindfold on.