NAME
BSON::Stream - Read BSON data from stream (file).
SYNOPSIS use BSON::Stream;
my
$file
=
shift
@ARGV
or
die
(
"Pleas specify a file to read!"
);
open
(
my
$INF
,
$file
) or
die
(
"Can not open file '$file':$!"
);
my
$bsonstream
= BSON::Stream->new(
$INF
);
while
(
my
$res
=
$bsonstream
->get) {
printf
(
"%s own %s apples\n"
,
$res
->{
'name'
},
$res
->{
'apples'
});
}
close
(
$INF
);
DESCRIPTION
BSON::Stream allows you to read one and one BSON record from a file and get it back as a Perl structure.
Reading from STDIN
use
BSON::Stream;
my
$bsonstream
= BSON::Stream->new(
*STDIN
);
while
(
my
$res
=
$bsonstream
->get) {
printf
(
"%s own %s apples\n"
,
$res
->{
'name'
},
$res
->{
'apples'
});
}
BSON files can quickly become very large. One common way of dealing with this is to compress them using gzip, then use zcat to uncompressed and pipe the raw BSON data into a program on the fly.
zcat eg/testdata/users.bson.gz | perl eg/synopsis-STDIN.pl
EXAMPLES
Please see the eg/
directory for further examples.
SEE ALSO
BSON
AUTHOR
Git
https://github.com/runarbu/PerlBSONStream
COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.