On Sun, 6 Jul 2003, Jonathan Peterson wrote: > Let's sat I've got a class that reads and writes data with methods like > read_item() and write_item(). Let's suppose I'd like the option of data > items being stored in different places like in RDBMS systems or Berkeley DB > files, or HTTP servers or whatever. > > One approach would be to have the main class Acme subclass Acme::DBI or > Acme::HTTP or Acme::CSV or whatever, so the base classes supplied > appropriate implementations of read_item() and write_item().
It would be more common for Acme::new to return an instance of a subclass. There's no reason in Perl why Acme::new has to return an Acme. Perhaps this will illustrate. sub new { my $class = shift; my $type = shift; $class .= "::$type"; return $class->new(@_); } S. -- Shevek http://www.anarres.org/ I am the Borg. http://www.gothnicity.org/