read($fp, my $buffer, 4); my $type_id = unpack('A4', $buffer); if ($type_id eq 'FORM') { ... }