BSON::Int64(3pm)
π BSON::Int64 π
okay bestie, so this is the BSON::Int64 page from the User Contributed Perl Documentation, and it's literally the moment you learn how to wrap a big ol' 64-bit integer in a BSON-friendly lil package. slay. let's get into it π¦
β¨ VERSION β¨
version v1.12.2 β that's the vibe. that's the version. periodt. π
πΈ SYNOPSIS πΈ
use BSON::Types ':all';
bson_int64( $number );
that's it. that's the whole thing. you import everything from BSON::Types, you call bson_int64 on your number, and you're done. main character energy fr fr. π
π DESCRIPTION π
okay so here's the tea: this module gives you a BSON type wrapper for a numeric value that would be represented in BSON as a 64-bit integer. that's its whole job. it's very good at its job. π«Ά
but listen β if the value won't fit in a 64-bit integer, an error will be thrown. no cap. so don't try to sneak a giant number in there thinking nobody will notice, because somebody (the module) will absolutely notice. π
and if you're on a Perl that doesn't have 64-bit integer support? then the value must be a Math::BigInt object. that's not a suggestion, bestie, that's the rule. π§
π¦ ATTRIBUTES π¦
value
a numeric scalar, babe. it will be coerced to an integer β so it's getting rounded/trimmed into shape whether it likes it or not. the default is 0. πΈ
β METHODS β
TO_JSON
okay this one's got layers, stay with me:
- on a 64-bit perl, it returns the value as an integer. simple. clean. iconic. β¨
- on a 32-bit Perl, it gets returned as a
Math::BigIntobject β and here's the warning, bestie β that will fail to serialize unless aTO_JSONmethod is defined for that object, or in packageuniversal. so like, define your method or it's not gonna work. π
and there's a whole extra vibe check: if the BSON_EXTJSON environment variable is true and the BSON_EXTJSON_RELAXED environment variable is false, then it returns a hashref compatible with MongoDB's extended JSON format, which represents it as a document like this:
{"$numberLong" : "223372036854775807"}
(extended JSON spec lives at https://github.com/mongodb/specifications/blob/master/source/extended-json.rst if you wanna go read it, iykyk π)
π OVERLOADING π
the numification operator, 0+, is overloaded to return the value. the full "minimal set" of overloaded operations is provided (per overload documentation), and fallback overloading is enabled. so it behaves like a number basically everywhere you'd expect. lowkey elegant, highkey obsessed. ππ₯
π AUTHORS π
- David Golden
<david@mongodb.com> - Stefan G.
<minimalist@lavabit.com>
two absolute 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
free software, free love, free license. periodt. π
and that's the whole page, bestie!! this was BSON::Int64 from perl v5.30.3, dated 2020-08-14. go forth and wrap your 64-bit integers 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