The stupid question is the question not asked | |
PerlMonks |
Re: Self-writing code revisitedby kcott (Archbishop) |
on Sep 06, 2013 at 01:02 UTC ( [id://1052642]=note: print w/replies, xml ) | Need Help?? |
G'day Statue, Welcome to the monastery. That's illegal; it's got nothing to do with the array:
If you didn't want a my variable, you could do this:
You could eval a string containing that code but the scope of the lexical variable so declared would only be that string:
If you're actually trying to write code that writes code, your best bet might be to output the generated code to a file (e.g. script_my_script_wrote.pl) which you could subsequently run in the normal fashion. For example, this code in your generating script:
Would write this line into script_my_script_wrote.pl (or whatever you call it):
[Aside: this is your first post so the title "Self-writing code revisited" doesn't make much sense. Perhaps a link to whatever you're revisiting would help to clarify what you mean.] -- Ken
In Section
Seekers of Perl Wisdom
|
|