in reply to Re: Help creating a function
in thread Help creating a function

Yes. I am looking for factory pattern. But this code
my $class = $classname . '::' . $type ; use $class;
is not working in perl. Throws syntax error.

Replies are listed 'Best First'.
Re^3: Help creating a function
by Anonymous Monk on Feb 17, 2011 at 05:45 UTC
      I tried Module::Load also. but no luck
      use Data::Dumper; print Dumper {A=>'testA',B=>'testB'};
      using 'use' statement as above code, I get the output as
      $VAR1 = { 'A' => 'testA', 'B' => 'testB' };
      but when i try loading the module using Module::Load as below, prints nothing.
      use Module::Load; load 'Data::Dumper'; print Dumper {A=>'testA',B=>'testB'};
Re^3: Help creating a function
by tospo (Hermit) on Feb 17, 2011 at 09:37 UTC
    oops sorry, yes that was wrong. Actually what I normally do is this:
    $class=~s/:{2}/\//g; $class.= '.pm'; require $class_path;
    But there is probably a better way of doing it.