How to tell if my program is being piped to another (Perl) -
"ls" behaves differently when output being piped:
> ls ??? bar foo > ls ??? | cat bar foo
how know, , how in perl?
in perl, -t
file test operator indicates whether filehandle (including stdin
) connected terminal.
there -p
test operator indicate whether filehandle attached pipe.
$ perl -e 'printf "term:%d, pipe:%d\n", -t stdin, -p stdin' term:1, pipe:0 $ perl -e 'printf "term:%d, pipe:%d\n", -t stdin, -p stdin' < /tmp/foo term:0, pipe:0 $ echo foo | perl -e 'printf "term:%d, pipe:%d\n", -t stdin, -p stdin' term:0, pipe:1
file test operator documentation @ perldoc -f -x
.
Comments
Post a Comment