Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??

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.


In reply to Re: sprintf number to string by stevieb
in thread sprintf number to string by jobsworth

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.