in reply to Testing filehandles

"but I can't test directly against the <FOO>"

I think there is one thing has not been quite straightened yet. In fact, you can test directly against <STDIN>, and that is absolutely not a problem. Let's fix the != problem others pointed out, and test with this code:

use strict; use warnings; while (<STDIN> ne "quit\n") { print ;#I intentionally leave this here, and you will see "Use of +uninitialized value in print at foo.pl line 5, <STDIN> line blah." }

As others pointed out, $_ does not contain what you entered, but I intentionally leave it as is.

The real point I want to make here is that, this piece of demo code does quit the while loop when you enter "quit\n", but does not quit on other input.

The code itself is not much useful, as $_ does not contain what you entered, and you don't have other variable does that. But I do want to have one fact corrected: you can test against <STDIN>.