# perldoc > BSON::Types

---
type: CommandReference
command: BSON::Types
mode: perldoc
section: 
source: perldoc
---

## Quick Reference
- `bson_int32(42)` — Wrap integer as 32‑bit BSON int
- `bson_double(3.14)` — Force BSON double type
- `bson_decimal128("1.5")` — Exact decimal precision
- `bson_time()` — Current UTC time to ms
- `bson_oid()` — Generate a new Object ID
- `bson_doc(x => 1, y => 2)` — Ordered BSON document

## Name
Helper functions to wrap BSON type classes

## Synopsis
perl
use BSON::Types ':all';
$int32 = bson_int32(42);
## Functions
- `bson_bytes($byte_string, $subtype?)` — Returns a `BSON::Bytes` object wrapping the string, optional subtype
- `bson_code($javascript, $hashref?)` — Returns a `BSON::Code` object wrapping JavaScript code, optional scope hash
- `bson_dbref($object_id, $collection_name)` — Returns a `BSON::DBRef` object
- `bson_decimal128("decimal_string")` — Returns a `BSON::Decimal128` wrapping exact decimal precision
- `bson_doc(key => value, ...)` — Returns a `BSON::Doc` object preserving key‑value order
- `bson_array(...)` — Returns a `BSON::Array` object preserving element order
- `bson_double(1.0)` — Wraps a double to force BSON double serialization
- `bson_int32(42)` — Wraps an integer as a 32‑bit BSON int
- `bson_int64(0)` — Wraps an integer as a 64‑bit BSON int
- `bson_maxkey()` — Returns the max key singleton
- `bson_minkey()` — Returns the min key singleton
- `bson_oid()` / `bson_oid($bytes_or_hex)` — Generates a new or wraps a provided Object ID (12‑byte OID or 24‑hex chars)
- `bson_raw($bson_encoded_bytes)` — Wraps an already‑encoded BSON document
- `bson_regex($pattern, $flags?)` — Wraps a PCRE regex with optional flags
- `bson_string("string")` — Wraps a string to force BSON UTF‑8 string serialization
- `bson_time($seconds_from_epoch?)` — Returns a `BSON::Time` (UTC, millisecond precision); uses current time if no argument
- `bson_timestamp($seconds, $increment)` — Returns `BSON::Timestamp` (not recommended for general use)
- `bson_bool($expr)` (DISCOURAGED) — Returns boolean true/false; for efficiency, use `boolean::boolean()` directly