package Service::Factory; use Service::XML; use Service::JSON; use warnings; use strict; my %SUPPORTED = ( xml => 'XML', json => 'JSON'); sub instantiate { my ($class, $plugin) = @_; die "Unknown plugin '$plugin'.\n" unless $SUPPORTED{$plugin}; my $subclass = "Service::$SUPPORTED{$plugin}"; return $subclass->new(@_[2 .. $#_]) } __PACKAGE__