open(my $fd, '<:raw', 'test') or die("Failed to open file: $!"); binmode($fd); read($fd, my $buf, 4); close($fd);