Re: No Gtk2 and no Perl utf8 bug (was: Re: Something-else-than-utf8 bug (was: Re: utf8 bug ?))



* Jörn Reder <joern zyn de> [2004-09-05 10:21]:
We learn: don't struggle with globals! Use lexicals! ;)

Or remember local().

Try this:

    sub replace { local $_ = shift; $_ }

Repeat after me:

    Always localize $_.
    Always localize $_.
    Always localize $_.

There are so many cases where forgetting that has bitten someone
in this way or that.

Of course the same is true for other global special variables,
but $_ is the one used most of them all.

I didn't even notice this problem because I localize reflexively
these days and don't even think about it anymore. Consequently I
can't remember the last time I've had such a nasty surprise.

Regards,
-- 
Aristotle
"If you can't laugh at yourself, you don't take life seriously enough."



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]