my $read; while ($read = read FILE, $char, 1) { print "got: $char\n"; } die "read error: $!" if not defined $read;