wageslave has asked for the wisdom of the Perl Monks concerning the following question:

The book Im learning perl from has very little information on the special variable $_ all it basically says is that if <STDIN> isnt assigned to a variable its assigned to $_ and it can be used with a foreach loop I've search some on the web but most of the tutorials I've run across have relativley little information on $_, although i've learned a bit more on it. one of the things I found out was that it works with a while loop, so I tried a few different ways of using it. but i cant figure out why it doesnt work for the second one and why the third one seems to be off by one every time it prints
print "first\n"; while (<STDIN>) { print; print "***\n"; last if(eof); } print "second\n"; while (<STDIN>!=eof) { print; print "***\n"; } print "\nthird\n"; while ((chomp($tst=<STDIN>))!=eof) {print $tst ; print "***\n"; }
I'm runing this on a windoze system. the first while statement works as I expect it to,basically you type something hit return it prints what you typed when you hit ctrl-z it exits.
the second one doesnt work, if you hit enter twice it exits out of the loop, from what I can guess is that $_ isn't being assigned, but no idea why it wont do the comparison .
The third one works buts its a lil off, after the second entry it prints stuff. from what I understand all 3 should produce the same output if someone could help me out and set me straight as to why the outputs are different I would greatly appreciate it