in reply to Readonly error on $_ again (better format, mehopes)

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.

Replies are listed 'Best First'.
Re (tilly) 2: Readonly error on $_ again (better format, mehopes)
by tilly (Archbishop) on Jan 05, 2001 at 17:01 UTC
Re: Re: Readonly error on $_ again (better format, mehopes)
by jeroenes (Priest) on Jan 05, 2001 at 17:08 UTC
    Aha, I see.

    I had assumed that $_ get's local in any sub. I can see the picture, thanx everyone!

    Jeroen
    I was dreaming of guitarnotes that would irritate an executive kind of guy (FZ)