You can't, exactly.  You have just overwritten $_ with the second loop.  The
only way you COULD do this is maybe by declaring $_ with local() somehow?  I
don't know.  Even if you could figure out how to do that, however, you would
be doing the same thing as creating a new variable, only you will be making
it a lot more complicated than it has to be.  If I were you (which,
understandably, I am not), I would stick with:

for(1..10){
  print $_\n\t";
    foreach my $inner(a..h){
      print "$inner\t";
    }
  print "\n";
}

-----Original Message-----
From: RTO RTO [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 09, 2002 2:33 PM
To: [EMAIL PROTECTED]
Subject: $_ variable question


Friends:

I have an outerloop with a list and so do I have an
inner loop with another list.

$_ variable points to list in the outer-loop or
inner-loop depending upon the scope. I prefer to not
use aliases. In such a case, when I am in the scope of
inner loop, can I access the looping variable on the
outer without using an explicit alias variable?

For ex:

for(1..10){
  print("$_\n\t");  # $_ is 1,2,3...
   for(a..h){
    print("$_\t");  # $_ is a,b,c...
                    # How can I refer to 1,2,3 here??
   }
  print("\n");
}



__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to