Dynamic object name question

Ian Knopke ian.knopke at gmail.com
Thu Jun 30 20:54:00 BST 2011


Hi everyone,

I have a whole list of subobjects of the form:

foreach my $t(@types){

    if ($t eq 'first'){
        Top::First->new(@args);
    } elsif ($t eq 'second') {
        Top::Second->new(@args);
    } elsif
     .... (add 20 more of these here)
    };
}

Since the arguments coming in match the object names (except for case)
there must be away to collapse this into something saner, but I don't
know how. Does anyone have any advice?


Ian Knopke


More information about the london.pm mailing list