in reply to How to a construct objects with variables as class names?

The problem looks to be with your call to new(). When you don't have new() defined in the current name space, and you call
new class, @args
Perl guesses that class::new() is defined and tries that. But you havn't given it a class name, you've given it a variable. You might try
$class->new( @args )
I've had some luck with that in the past. By the way, 'pointy' is the preferable way to invoke methods on objects and classes, as it eliminates the uncertainty of who's method is being called. Also, make sure that $class has been required, and actually is compiled.

Replies are listed 'Best First'.
Re: Re: How to a construct objects with variables as class names?
by joecamel (Hermit) on Feb 14, 2001 at 11:32 UTC
    Thanks Adam,

    I changed the method to the following, which worked perfectly:

    my $fullClass = "SuperWidget::Widget::" . $className; my $widget = $fullClass->new($widgetID);
    I normally use the -> operator for method calls, but figured the only way to dynamically name an object was with the new class (@args) format.

    joecamel