Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

RE: Runtime loading of arbitrary objects

by merlyn (Sage)
on Aug 21, 2000 at 17:26 UTC ( #28800=note: print w/replies, xml ) Need Help??

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();
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://28800]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2021-04-17 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?