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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can a class constructor create an instance of a derived class and return it? Or, can objects transmute into other objects?
by poodad (Initiate) on Sep 28, 2017 at 16:19 UTC | |
by Corion (Patriarch) on Sep 28, 2017 at 16:57 UTC |