package Factory; use MooseX::AbstractFactory; implementation_class_via sub { shift }; package main; use strict; use warnings; my %movies_data = ( Firefly => { title => 'Firefly', start_year => '2002', end_year => '2003', media => 'TV', # <--- real class name }, 'The Avengers' => { title => 'The Avengers', start_year => '1998', end_year => '', media => 'Movie', # <--- real class name based_on => 'television series', company => 'Thames Television', }, ); my @objects; for (keys %movies_data) { push @objects, Factory->create( $movies_data{$_}{media}, $movies_data{$_} ); } print $_->to_string, $/ for @objects;