in reply to is $_ thread-safe?

from the mod_perl guide, it is stated:
Special Perl variables like $| (buffering), $^T (script's start time), $^W (warnings mode), $/ (input record separator), $\ (output record separator) and many more are all true global variables; they do not belong to any particular package (not even main::) and are universally available. This means that if you change them, you change them anywhere across the entire program; furthermore you cannot scope them with my(). However you can local()ise them which means that any changes you apply will only last until the end of the enclosing scope. In the mod_perl situation where the child server doesn't usually exit, if in one of your scripts you modify a global variable it will be changed for the rest of the process' life and will affect all the scripts executed by the same process. Therefore localising these variables is highly recommended, I'd say mandatory.
so you do have to do something with the special variables or expect clashes... wow, my boss was riht. and I thought he was so stupid.

Replies are listed 'Best First'.
(MeowChow) Re2: is $_ thread-safe?
by MeowChow (Vicar) on Aug 31, 2001 at 23:01 UTC
    Most competent uses of globals such as $_, $/, etc, will involve localizing them, so this is not a problem unless you are coding poorly to begin with. In the specific case you've mentioned, grep auto-localizes $_, so there's nothing to worry about.
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print