Storable

Chapter 7 - Great CPAN Modules
by?Sam Tregar?
Apress ? 2002
has companion web siteCompanion Web Site

The Storable module provides serialization and deserialization of arbitrary Perl data structures. Serialization is the process of transforming a data structure into a string, and deserialization is the reverse—transforming a string back into a data structure. Serialization is a precursor to many other interesting programming projects—mobile agents, object persistence, persistent caching, and more.

When Raphael Manfredi created Storable, there were existing solutions to data serialization on CPAN already. Chief among them was the excellent Data::Dumper by Gurusamy Sarathy, which is still used frequently today. The problem with Data::Dumper, and other serialization systems, as Raphael saw it, was that they were too slow. Storable solved this problem by digging deep into the guts of Perl with C code (which you'll learn about in the next few chapters). As a result, Storable was able to offer serialization at a greatly reduced runtime cost.

Storable is a great example of doing one thing and doing it well. As such, Storable has become the basis for many other modules that add services on top of basic serialization.

Another key to Storable's success is the simplicity of its interface. All you need to get full use out of the module are two functions—store() and retrieve()—both of which are exported by default. More complicated usages are supported by a handful of extra functions that can be imported by request. Contrast this with Data::Dumper, which offers a slightly greater range of functionality, but at the price of a confusing functional and OO interface that uses an odd convention for subroutine naming (Dumper() and Data::Dumper->Dump(), for example).

A testament to Storable's success is that when Raphael recently announced his retirement from the Perl community, the perl5-porters[15] took over maintenance of Storable. Storable is now included as a core Perl module.

[15]The perl5-porters are responsible for the maintenance and development of Perl 5.



Writing Perl Modules for CPAN
Writing Perl Modules for CPAN
ISBN: 159059018X
EAN: 2147483647
Year: 2002
Pages: 110
Authors: Sam Tregar

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net