Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Help creating a function

by varghees (Novice)
on Feb 17, 2011 at 05:35 UTC ( [id://888646]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://888646]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-25 15:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found