I have some code that is in production. There isn't a test environment for this code. So I would like to be able to modify it without risk to the development team.

So I've thought about this idea.

program.pl is the file that our engineering team uses.

I must enter program.pl, becaues it is called by something else that I can't change. I want to debug/work on program.pl.

I thought maybe I could take program.pl and copy it to my_program.pl.

Then at the top of program.pl, do some kind of magic that will execute my_program.pl code if an environment variable is set. Otherwise, it just executes the code that already exists in program.pl.

All I would need to do is add a few lines at the top of program.pl, very low risk.

So I'm looking for options. I thought there was a command that would let perl take in a string of perl code and then execute it, but I don't know if seeing the same sub-routines defined twice in a perl file would cause a problem, most likely.

Or maybe the simple solution is to just put a condition, and execute my second perl script, passing all the arguments to it, and then exiting if an environment variable is set.

Re: [srhadden] Wanting to debug live code by using a "bypass"?
[In reply to]

Can't Post

// is an operator introduced with Perl 5.10. It returns its right operand if its left operand is undef.

q() is just a different way to write single quotes, i.e. q(abc) is the same as 'abc'. I sometimes prefer q(), in particular in forums where proportional font is used, because two single quotes '' are sometimes misread as one double quotes ", so the q() notation is clearer.

$Config{perlpath} is supposed to return the path to that Perl installation which was used to invoke your Perl program (since you might have several Perl on your machine). That way, it ensures that your my_program.pl will be executed with the same Perl. I'm surprised that you don't get the whole Path to your Perl. Not important in this context, but maybe interesting to find out, why this is the case.