I just viewed the html source and everything looked fine there, try wrapping the whole thing with code tags maybe?

The problem it that in selfcontrol you assign to $_. In the for loop in your calling code $_ has been aliased to 'Operator' and you are trying to assign to that. In effect you are trying to do 'Operator' = 'foo'; which is not allowed.

The actual problem is that $_ is by default global between all subs in all packages (a topic which has been discussed on this site several times). The solution: start subs where you use $_ with local $_; or avoid $_ in non innermost loops (like your workaround did) or in this case use a different switch method such as:

for ($ref) { last unless $_; last if /REF/; return $self; }
Which works because for loops automatically localize $_.
I don't feel like saying more but you might want to look for the nodes which complain about $_, I remember there being at least 2.

In reply to Re: Readonly error on $_ again (better format, mehopes) by repson
in thread Readonly error on $_ again (better format, mehopes) by jeroenes

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.