[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] $_ global?




These "global" variables are not really global variables.  All these
variables are local to main.

Ro Ke


On Thu, 13 Feb 1997, Terry Lynch wrote:

> 
> It was my understanding that most variables are global, including '$_' .  I don't have the new camel book yet; perhaps this has changed in perl 5.
> 
> Here is some code that seems to show '$_' as a local variable:
> ------------------------------
> $_ = "Am I global?";
> print "$_\n";
> @marbles = ('red','orange','yellow','green','blue','indigo','violet');
> foreach (@marbles) {print "$_\n";}
> print "$_\n";
> ------------------------------
> 
> And here are the results:
> ------------------------------
> Am I global?
> red
> orange
> yellow
> green
> blue
> indigo
> violet
> Am I global?
> ------------------------------
> 
> Why is '$_' acting as a local variable? 
> I want it to be global, so how to make it work?
> 
> 
> Thanks everyone,
> 
> Terry Lynch
> 
> 
>