$s should be ok here. I suspect that $$p ( $$p=$$p-1;)could be the cause here? I'm not sure as I didn't get that error in my simple testing. I don't see much point in using a ref to $p. I would pass p itself, change this $$p line to $p--; and then return($p); at the end of the sub. I suppose its also possible that you did pass $p instead of \$p and this error message is a referencing error.

Update: Looked again. $CFG::CFG[$s]->{'CMD'}; also looks a bit odd. I'd like to see some more code and explanation of what you think that this CFG data structure looks like. Maybe you intend an array of Hash? I'm not sure from this code. $CFG isn't defined anywhere that I can see. What I said above shouldn't actually matter from functionality or compile errors. If you are going to use a ref, passing a ref to this $CFG thing is the place. Normally passing a ref to a scalar is not necessary or desirable as Perl can return multiple lvalues.

Update Again: I didn't see the missing $s=0 in the for loop. Even so this code sans $CFG::CFG[$s]->{'CMD'}; compiled and ran on my Perl 5.10 machine.


In reply to Re^3: Useless use of private variable by Marshall
in thread Useless use of private variable by Sun751

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.