in reply to Re: Nicest way of getting STDIN a beauty contest
in thread Nicest way of getting STDIN a beauty contest

It will wait in perpetuity before exiting if no input was provided to STDIN and no file was specified.

So yes magic <> would have worked if I didn't want it to exit.

If that was all I wanted a simple ...below... would have worked.

my @hosts = <>;

Replies are listed 'Best First'.
Re^3: Nicest way of getting STDIN a beauty contest
by shmem (Chancellor) on Oct 09, 2009 at 09:30 UTC
    It will wait in perpetuity before exiting if no input was provided to STDIN and no file was specified.

    How long do you want it to wait? Your program has to wait until I'm done with the current line. How does it tell that I've not just gone away for a coffee break?

    However, if STDIN is closed (e.g. by typing ^D at a terminal, or by closing a pipe after no input) the simple solution

    chomp( my @hosts = <>); die "usage: foo hosts\n" unless @hosts;

    will do what you want.