eval with parameters

Matt S Trout dbix-class at trout.me.uk
Sat May 20 01:17:14 BST 2006

Peter wrote:
> Hello,
> If I need to eval some code string that uses some calling function's 
> local variables as parameters what syntax should I use?
> Case like this:
> sub  someFunction {
> ($param1,$param2,$codeString) = @_;
> # $param1 & $param2 - some object or pseudohash variables
> # $codeString - some external code string that uses $param1 & $param2 as 
> variables
> # and returns some value
> return eval($codeString); }
> (I suspect that is stupid question, but I have never do something like 
> this and I did not find something like this in my manuals yet)

That's because you almost certainly don't want to do this.

Step back. Explain what you're trying to achieve.

      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

More information about the london.pm mailing list