BSON::Int32(3pm)
β¨ BSON::Int32 β¨
okay bestie, so this is BSON::Int32, a lil Perl module from the User Contributed Perl Documentation collection, and it's basically the bouncer for 32-bit integers in BSON-land π
version v1.12.2 β that's the vibe, that's the era π
πΈ SYNOPSIS πΈ
the way you use it is literally this:
use BSON::Types ':all';
bson_int32( $number );
that's it. that's the whole entrance π¦
π DESCRIPTION π
so this module gives you a BSON type wrapper for a numeric value that would be represented in BSON as a 32-bit integer. it's giving "I hold one number and I hold it responsibly" π
π¨ lowkey important: if the value won't fit in a 32-bit integer, an error will be thrown. not a warning, not a shrug, an actual error. the vibes will not be saved. π
π¦ ATTRIBUTES π¦
value
a numeric scalar, bestie. it gets coerced to an integer (so don't come in here with your decimals and your chaos, it's getting rounded into int-ness). the default is 0 β neutral, humble, main character on a rest day π
β METHODS β
TO_JSON
returns the value as an integer. periodt.
but okay here's the plot twist π: if the BSON_EXTJSON environment variable is true and the BSON_EXTJSON_RELAXED environment variable is false, then it returns a hashref that's compatible with MongoDB's extended JSON format β the spec lives over at https://github.com/mongodb/specifications/blob/master/source/extended-json.rst β and it represents the thing as a document like this:
{"$numberInt" : "42"}
so it's not just 42, it's "42" dressed up in a whole $numberInt moment. iconic, honestly. π
π OVERLOADING π
the numification operator, 0+, is overloaded to return the value. and not just that one β the full "minimal set" of overloaded operations is provided (per the overload documentation, iykyk), and fallback overloading is enabled. so your object knows how to behave in arithmetic society. it's socially fluent. we love that for it π«Ά
π AUTHORS π
- David Golden
<david@mongodb.com> - Stefan G.
<minimalist@lavabit.com>
two icons. two legends. we stan π
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
and that's the whole page, bestie π no cap, every flag, every default, every warning β all accounted for. this one's rocking perl v5.30.3 and it's dated 2020-08-14, so go forth and wrap your ints responsibly. mwah ππ§β¨
π¦ where this page comes from
- debian bookworm: libbson-perl 1.12.2-1 Β· Apache-2.0
- ubuntu jammy: libbson-perl 1.12.2-1 Β· Apache-2.0
- ubuntu noble: libbson-perl 1.12.2-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms