On Mon, 2006-08-28 at 12:27 +0200, John Cortland Morgan (ZG/ETK) wrote:
>
> > This will test for a pipe
>
> > #!/usr/bin/perl
> > # -t tests if a tty is input, else it's a pipe
> >
> > if (@ARGV == 0 and -t) {
> > die "Usage: $0 INPUT\n";
> > }
> >
> > while (<>) {
> > ## process input file(s) here
> > }
> > __END__
>
>
> The problem(s) with using -t and <> (as above) are:
>
> if you give only command line line options, the program will
> hang waiting for input.
>
If you use getopts it will consume the options, just put the test after
the getopts processing.
Other alternative is to use a simple shift.
--
Ken Foskey
FOSS developer
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>