in reply to bless!!
You mean like a factory method? This is done because we may not know the exact subclass we want to use until runtime. For instance, I've got a project I'm working on now where we want to generate different reports in various formats based on the info out of a database. It works by taking the type of report the user wants and looking up (via a hash) which subclass is for that report type. A factory method then blesses a reference into that class and passes the database info in. From there, the subclass can generate whatever kind of data it wants based on what it gets from the database.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
|
|---|