Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Don't know how to make a module for this repeating code

by Anonymous Monk
on Nov 25, 2012 at 10:21 UTC ( #1005474=note: print w/replies, xml ) Need Help??


in reply to Re^2: Don't know how to make a module for this repeating code
in thread Don't know how to make a module for this repeating code

can I eval() some text which return from a package that carrying the script body etc..

What does that mean?

  • Comment on Re^3: Don't know how to make a module for this repeating code

Replies are listed 'Best First'.
Re^4: Don't know how to make a module for this repeating code
by exilepanda (Pilgrim) on Nov 27, 2012 at 05:24 UTC
    umm... perhaps I can create something like this:
    package ExtConstructor; sub new { return <<" CODE"; eval 'use parent "parent::classes"'; sub new { return bless $_[0]->SUPER::new(); } CODE } 1; package Interface::Module; use ExtConstructor; my $code = new ExtConstructor; eval $code; # so that the constructor code created on-the-fly 1; package main; use Interface::Module; my $obj = new Interface::Module;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005474]
help
Chatterbox?
[stevieb]: w00t! my i2c module actually works, and it works well!

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2017-06-22 22:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.