Re: using string as module

2014-11-08 Thread Uri Guttman
On 11/08/2014 11:38 AM, Shawn H Corey wrote: On Sat, 8 Nov 2014 17:48:31 +0200 Shlomi Fish wrote: The correct syntax is simply (untested): my $foo = "MyFoo::${pgm}Bar"->new; FYI: That is called a symbolic reference. For more information, see `perldoc perlref` and search for /Symbolic

Re: using string as module

2014-11-08 Thread Shawn H Corey
On Sat, 8 Nov 2014 17:48:31 +0200 Shlomi Fish wrote: > The correct syntax is simply (untested): > > my $foo = "MyFoo::${pgm}Bar"->new; FYI: That is called a symbolic reference. For more information, see `perldoc perlref` and search for /Symbolic references/ BTW, symbolic references are n

Re: using string as module

2014-11-08 Thread Kent Fredric
On 9 November 2014 05:27, Ron Bergin wrote: > In fact, I > almost never use or suggest using eval. > eval itself is not evil. Its just *string* eval becuase that involves arbitrary code interpolation. Non-string eval is of course potentially written as "try" in other languages ( not exactly,

Re: using string as module

2014-11-08 Thread Ron Bergin
Uri Guttman wrote: > On 11/08/2014 10:40 AM, Ron Bergin wrote: >> you could accomplish it with the use of eval. >> >> my $foo = eval "MyFoo::${pgm}Bar->new"; > > ewww. never use string eval for something as simple as that. > > my $foo = "MyFoo::${pgm}Bar"->new() ; > > that is just fine there. the c

Re: using string as module

2014-11-08 Thread Uri Guttman
On 11/08/2014 10:40 AM, Ron Bergin wrote: 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 = MyFo

Re: using string as module

2014-11-08 Thread Shlomi Fish
Hi Billy, please reply to all recipients. On Fri, 7 Nov 2014 13:17:19 + "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

Re: using string as module

2014-11-08 Thread Ron Bergin
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; > …