BSON::ObjectId - ObjectId data element for BSON
version 0.16
use BSON; my $oid = BSON::ObjectId->new; my $oid2 = BSON::ObjectId->new($string); my $oid3 = BSON::ObjectId->new($binary_string);
This module is needed for BSON and it manages BSON's ObjectId element.
Main constructor which takes one optional parameter, a string with ObjectId. ObjectId can be either a 24 character hexadecimal value or a 12 character binary value.
my $oid = BSON::ObjectId->new("4e24d6249ccf967313000000"); my $oid2 = BSON::ObjectId->new("\x4e\x24\xd6\x24\x9c\xcf\x96\x73\x13\0\0\0");
If no ObjectId string is specified, a new one will be generated based on the machine ID, process ID and the current time.
Returns or sets the ObjectId value.
$oid->value("4e262c24422ad15e6a000000"); print $oid->value; # Will print it in binary
Returns true if the 24 character string passed matches an ObjectId.
if ( BSON::ObjectId->is_legal($id) ) { ... }
The string operator is overloaded so any string operations will actually use the 24-character value of the ObjectId.
This module is thread safe.
BSON
minimalist <minimalist@lavabit.com>
David Golden <david@mongodb.com>
This software is Copyright (c) 2015 by minimalist and MongoDB, Inc..
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
To install BSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BSON
CPAN shell
perl -MCPAN -e shell install BSON
For more information on module installation, please visit the detailed CPAN module installation guide.