Somehow this problem is by designIndeed.
but I wonder if there is a way to avoid this.My favourite solution is to make the script such a shallow and simple wrapper around a module (and put all the logic into the module) that it doesn't really need any testing. Consider
#!/usr/bin/perl use NaServer qw(run); run(@ARGV);
And then do all the testing on NaServer::run instead. Since it's located in a module, you just use it once in the test script, apply the monkey patching you need, and just test as usual.
Other solution:
1) put a package YourPackage; in front of the string you eval, and after the run clean the namespace with an appropriate CPAN module
2) just as 1), but use a separate package name for each run, thus avoidng name collisions.
In reply to Re: string-eval code more than once
by moritz
in thread string-eval code more than once
by LANTI
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |