in reply to Dynamically wrapping multiple modules

eval is ok if you can verify the user input. I would recommend creating a hash of allowed input, i.e., country codes:
my %code = ( au => 'AU', fr => 'FR' ); foreach my $cc (@country_code) { croak("Country code $cc is not available") unless exists $code{$cc} +; eval( "require MyModule::$code{$cc}" ); croak("Unable to locate MyModule::$code{$cc}") if $@; }

-Mark

Replies are listed 'Best First'.
Re: Re: Dynamically wrapping multiple modules
by BigLug (Chaplain) on Apr 19, 2004 at 09:28 UTC
    I should point out that I don't have the full country list. I'm not too keen on keeping it up to date with the full ISO country list ! However I guess I can validate it with a regex: croak if $cc!~/^[a-z]{2}$/i
    "Get real! This is a discussion group, not a helpdesk. You post something, we discuss its implications. If the discussion happens to answer a question you've asked, that's incidental." -- nobull@mail.com in clpm