There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
If you prefix eval strings with in your filter, then your filter will be re-loaded when the string is eval'd. However, when I tried this -- using Filter::Simple as I thought that I could use it's separation of code and strings to my advantage -- it gets very confusing about what stage you are at. Everytime I thought I was close to having something work, another gotcha popped up. So, I thought I pass the basic idea along and see if it give you better inspiration than I. :) Update: dws pointed out that the above code wasn't responsible for my percieved partial success. The use Foo; will happen before the delete $INC{'Foo'}. The delete $INC{'Foo'} needs to delete $INC{'Foo.pm'} anyway. The thing fooled me was a redundant piece of test code in the external file....D'oh. Anyway, having re-examined it, I did get a little closer, but still way short of anything that could be called successful. The filter
The test program
The external program
The output
As you can see, the Filter is being loaded twice, and the text within the evald string has bee uppercased (too much of it, but that's a detail :). I did have the require half working at one point, by using eval 'use Filter::Test;' do{ local *ARGV = 'file'; <> };, but it starts getting very complicated when you start trying to filter an eval'd require file that contains evals that contains requires.... Recurse; See Recurse; 8^o. I can't wrap my brain around it any longer, but maybe it will inspire you, or convince you to try a different route, which might be an equally valid assist :) Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller If I understand your problem, I can solve it! Of course, the same can be said for you. In reply to Re: Source filters in eval/require
by BrowserUk
|
|