Help for this page

Select Code to Download


  1. or download this
    $class_name = "Calvin::Hobbes"; # from some value above
    my $new_object = $class_name->new;
    
  2. or download this
    if (grep $class_name eq $_, qw(Calvin::Hobbes Peter::Gabriel Dog::Day:
    +:Afternoon)) {
      # must validate the name, or security holes will run rampant
      eval "require $class_name"; die $@ if $@;
      $object = $class_name->new;
    }
    
  3. or download this
    my %make_a = qw(
      Calvin::Hobbes new
    ...
      }
      $object = $class_name->$constructor();
    }