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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/