!#/usr/bin/perl use Fcntl; open( FH, "<", "/bin/cat" ) or die "cannot open file: $!\n"; $flags = fcntl(FH, F_GETFL, 0) or die "Can't get flags for the file: $!\n"; if( $flags | O_BINARY ) { print "OPEN FOR BINARY\n" }