in reply to Checking for STDIN

-t STDIN

Replies are listed 'Best First'.
Re^2: Checking for STDIN
by Anonymous Monk on Jul 30, 2008 at 01:35 UTC
    -t will not work because I am using my script in a cron job sometimes.

      What do you mean?!

      Save this code to a file and test it.

      #!/usr/bin/perl -wl use strict; open my $fh, '>', '/tmp/test.log' or die $!; print $fh 'STDIN ', ( -t STDIN ? 'IS' : 'is NOT' ), ' available' or di +e $!; close $fh or die $!;
        In a cron job -t would evaluate to false which in my case would mean my script would think info is being piped to it when I have a commandline option -logfile <file> being used to specify input.