#!/usr/bin/perl use strict; use warnings; open my $fh, '<', '/dev/null'; binmode($fh); my $buffer; # read one byte my $r = read($fh, $buffer, 1); if($r > 0) { print "read something\n"; } else { print "nothing to collect\n"; } close($fh);