--On Thursday, September 25, 2003 20:40 -0400 Dan Anderson <[EMAIL PROTECTED]> wrote:


        First, thank you for your help.  Second, please bear with me as
I'm a perl noob.

I assume that $_ is the last thing gotten by <STDIN>.

Nope. ;-) $_, in the context listed in his example, is the value of the current element of the array the loop is looping over. The array just happens to be <STDIN>.


will regexes always default to using $_?  I think that's right, but
when I try:

Yes, regexes always default to $_.


while (!(<STDIN> =~ /QUIT/))
{ push @stack, $_; }
print @stack;

it doesn't print anything (although it compiles).

You are now using a boolean value for the test in the while loop. (Eg: whether the test was successful.) Therefore the $_ trickery doesn't apply, and $_ stays whatever it was before the loop. (I think. Regardless it is no longer the last line read from <STDIN>.)


So I typed use warnings; at the top and I get a lot of errors about
using an uninitialized variable (@stack).  Now I assume that @stack
comes into scope as local to that while loop, but typing:

Actually, it would come into scope as a global.


my @stack;
our @stack;
local @stack;

Before the loop do nothing. Am I missing something?

Should they do anything? (Besides define @stack, and disabling the warning since you have now defined it explicitly.) All they say is to define @stack in a smaller scope than global.


Daniel T. Staal

---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------

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



Reply via email to