Patton, Billy N wrote:
> I currently have something like this
> use MyFoo::ABCBar;
> use MyFoo::DEFBar;
> use MyFoo::HIJBar;
> my $fooABC = MyFoo::ABCBar->new();
> â¦
>
> What I would like to do is
>
> foreach $pgm ( âABCâ , âDEFâ , âHIJâ) {
> my $foo = MyFoo::{$pgm}Bar->new;
> â¦
> }
>
> This gives me an error.
> What is the correct syntax?
I don't see any valid reason why you'd want to do that, but if that's what
you want, you could accomplish it with the use of eval.
my $foo = eval "MyFoo::${pgm}Bar->new";
--
Ron Bergin
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/