LPM: Scope of $_

Rich Bowen rbowen at rcbowen.com
Tue Jan 11 21:14:03 CST 2000

> >
> > So you tell me...am I confused or disappointed?  I looked in Learning Perl
> > and Programming Perl, but didn't find the answer.  Is there something I can
> > do to protect $_ ?  I tried my ($_) but perl didn't like that.
> >
> You're disappointed, and rightly so.  There's only one $_ and a change made
> to it anywhere is reflected everywhere else.

But $main::_ is not the same variable as $rtf2html::_ is it? I know that
using $_ all over the place can break things, but I figure that when you
were in another name space, as in calling a function in another module,
that you'd be (reasonably) safe. No?

Lexington Perl Mongers - http://lexington.pm.org/
PGP Key - http://www.rcbowen.com/pgp.txt

More information about the Lexington-pm mailing list