use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); fcntl(FILE, F_SETFL, O_NONBLOCK | (fcntl(FILE, F_GETFL, 0) or die "can't get flags: $!")) or die "can't set flags: $!"