Class::Printable - A base class for Printable objects
package MyObject; our @ISA = ('Class::Printable');
Sometimes it is nice to have your objects return something a bit more complex then MyObject=HASH(0x3bac438) when you print them. This module is a base class for adding that capability to your objects. This is a very simple class which when used as a base does not actually change the normal perl stringification behavior unless you override the classes toString method. Basically, it is there if you need it, and silent otherwise.
MyObject=HASH(0x3bac438)
print
toString
This implementation actually just calls stringValue so that your object will still retain the normal perl stringification behavior. However, if your subclass overrides this method, then the return value of it will be used whenever perl needs to stringify your object.
stringValue
This will return the unmolested stringification of your perl object.
This operator, the stringification operator, is implemented with toString.
None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.
I use Devel::Cover to test the code coverage of my tests, below is the Devel::Cover report on this module test suite.
------------------------ ------ ------ ------ ------ ------ ------ ------ File stmt branch cond sub pod time total ------------------------ ------ ------ ------ ------ ------ ------ ------ Class/Printable.pm 100.0 n/a n/a 100.0 100.0 100.0 100.0 ------------------------ ------ ------ ------ ------ ------ ------ ------ Total 100.0 n/a n/a 100.0 100.0 100.0 100.0 ------------------------ ------ ------ ------ ------ ------ ------ ------
This class is very simple, and is really nothing more than a wrapper around the stringification operator capabilities of overload.
stevan little, <stevan@iinteractive.com>
Copyright 2004 by Infinity Interactive, Inc.
http://www.iinteractive.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Class::Printable, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Printable
CPAN shell
perl -MCPAN -e shell install Class::Printable
For more information on module installation, please visit the detailed CPAN module installation guide.