Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: sprintf number to string

by stevieb (Canon)
on Aug 14, 2015 at 13:53 UTC ( [id://1138582] : note . print w/replies, xml ) Need Help??


in reply to sprintf number to string

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.

-stevieb

Replies are listed 'Best First'.
Re^2: sprintf number to string
by jobsworth (Novice) on Aug 17, 2015 at 06:51 UTC
    yes that is it. there was a my ($c); inside the subroutine which i moved outside. i always use strict. i never use warnings. i will do so. many thanks for your time and accurate observation. john