Why have the package SNMPDevice be a class at all?
package SNMPDevice; use strict; use SNMPDevice::CiscoWLC; use SNMPDevice::Juniper; use SNMPDevice::Generic; sub new { my( $class, %args ) = @_; my $instance_class; if( $args{ cisco } ) { $instance_class = 'SNMPDevice::CiscoWLC'; } elsif( $args{ juniper }) { $instance_class = 'SNMPDevice::Juniper'; } else { $instance_class = 'SNMPDevice::Generic'; }; return $instance_class->new( %args ); } 1;
In reply to Re: Can a class constructor create an instance of a derived class and return it? Or, can objects transmute into other objects?
by Corion
in thread Can a class constructor create an instance of a derived class and return it? Or, can objects transmute into other objects?
by poodad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |