BSON::Stream - Read BSON data from stream (file).
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);
BSON::Stream allows you to read one and one BSON record from a file and get it back as a Perl structure.
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
Please see the eg/ directory for further examples.
eg/
BSON
Runar Buvik CPAN ID: RUNARB runarb@gmail.com http://www.runarb.com
https://github.com/runarbu/PerlBSONStream
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.
To install BSON::Stream, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BSON::Stream
CPAN shell
perl -MCPAN -e shell install BSON::Stream
For more information on module installation, please visit the detailed CPAN module installation guide.