Someone on one of the zillion Perl mailing lists wanted to know how to have an object whose class was determined only at runtime. Many solutions were posted that involved messy evals, but I coded up this one that uses the underused autouse.

I was tempted to call this "Objects of unusual size", but that's another story. {grin}

my %objects; for my $class (qw(Report::object1 Report::object2)) { require autouse; autouse->import($class, "$class\::new"); $objects{$class} = $class->new; }
or, if you can determine the possible range of $class at the top of the program, you can use autouse in the more traditional way:
use autouse qw(Report::object1 Report::object1::new); use autouse qw(Report::object2 Report::object2::new);