Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Code Execution in Perl ? 1

Status
Not open for further replies.

iamberb

Programmer
Jul 14, 2005
15
DE
Hi,

Is there some way to execute dynamic code in perl. Something like reflection in other languages.

Lets assumed I have a field containing:
$tag1="test";
$check="$tag1 eq ""hallo""";
if (dyn($check))
{

}
So I want before executing the if to assume that instead of dyn($check) the content is dynamically used as condition.

I hope someone can help me with this.
brg Robert
 
Hello Robert,

Careful now.... Executing just any old code is generally considered a Bad Thing. Look closely, for instance, at anything a user might have typed in or is read from a file.

Mike

You cannot really appreciate Dilbert unless you've read it in the
original Klingon.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884

 
For instance - someone could mail themselves your password file


Kind Regards
Duncan
 
Thanks for the eval hint. I just have some problem in using it. I get when using:
my $code = eval "sub { return check_name(true); }";
Undefined subroutine &main:: called at eval_test.pl line 5.
but
my $code = eval "sub { return check_name(); }";
is OK.
What i am doing wrong ?
I tried as well:
my $code = eval "sub { return check_name("true"); }";
my $code = eval "sub { return check_name(""true""); }";
my $code = eval "sub { return check_name(\"true\"); }";



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top