CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Wanting to debug live code by using a "bypass"?



Dec 28, 2011, 4:06 PM

Post #1 of 5 (2309 views)
Wanting to debug live code by using a "bypass"? Can't Post

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. is the file that our engineering team uses.

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

I thought maybe I could take and copy it to

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

All I would need to do is add a few lines at the top of, 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.

Thank you for any ideas.


Dec 29, 2011, 5:55 AM

Post #2 of 5 (2279 views)
Re: [srhadden] Wanting to debug live code by using a "bypass"? [In reply to] Can't Post

If you want to do the decision based on an environment variable, you could write the following at the first line in

use Config; 
if($ENV{MY_MAGIC_VAR}//q()) {
exec($Config{perlpath},$ENV{MY_MAGIC_VAR},@ARGV) or die "exec failed ($!)";

Hence, by setting MY_MAGIC_VAR to the path of your, this would be executed.


Dec 29, 2011, 3:20 PM

Post #3 of 5 (2249 views)
Re: [rovf] Wanting to debug live code by using a "bypass"? [In reply to] Can't Post

Thanks, I wish I could say I knew what some of that meant :).

//q(), and $Config{perlpath} just returns "perl", nothing else. Is there something important about some of those extra pieces? Thanks again.


Dec 29, 2011, 10:18 PM

Post #4 of 5 (2241 views)
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 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.


Dec 30, 2011, 1:30 PM

Post #5 of 5 (2227 views)
Re: [rovf] Wanting to debug live code by using a "bypass"? [In reply to] Can't Post

Thanks! We've been stuck with 5.8 for a looong time, so probably why I haven't see the // used.

Thank you!


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives