in reply to Update a perl script when its running

Quite possibly it is me who is misreading the question, but I have the feeling that you've received complicated answers to a very simple question (and to a question calling for a much simpler answer). I reread again twice the original question and I really think it was misunderstood.

My understanding of your question is the following (making it a bit simpler to better clarify): suppose that I have a Perl program running and taking, say, 24 hours to execute. While this job has been running for, say, 12 hours, I want to fire another instance of the same program, but after having modified the code. Will this affect the job that is already running?

If my understanding is correct, then the answer is no, it will not affect the job already running (which will continue to use the old code), and the new job will use new code. The reason for that is that when you fire a Perl program, Perl reads the source into memory, compiles it in memory and generates some form of internal code, and then runs that internal code. Once the internal code has been generated, Perl will not go back to the source code. So the program already running will not be affected by a change in the file containing the source code, because it is never going to go and look at it again. And the new program will happily take the (new) source code as it is when it is launched. So you should not run into any problem.

My apologies if it is me who misunderstood the original question.

Je suis Charlie.
  • Comment on Re: Update a perl script when its running

Replies are listed 'Best First'.
Re^2: Update a perl script when its running
by locked_user sundialsvc4 (Abbot) on Feb 11, 2015 at 00:47 UTC

    Laurent, as one of those contributors of a “complicated answer” ... and framing this response, of course, as merely an impersonal, technical discussion among software engineers ... I think it might be useful here for me to elaborate on the thoughts that guided my particular suggestion.   (Not to defend, per se, but rather to illustrate ...)

    To my way of thinking, an over-arching technical consideration of “a program that takes 24 hours to execute” is that the very non-zero possibility exists that this program might, (koff, koff ... say it isn’t so ... say that my pager didn’t just go off at OMGwhattimeisit?...) run for 23.75 hours.

    Oops.™

    And so, like it or not, that job must be re-run.   Exactly that job.   ...   Provably that job.

    If you have replaced the original source-code ... the code that existed at the precise moment when that job was launched ... with another version of the same source-code, then you by-definition cannot “exactly, provably, re-create” that job.

    “Well, okay, is that actually an issue?”   Only the OP can tell, but my “forever err on the side of caution” tacit assumption was that it might be.   And this, for the record, is the thinking that therefore guided my previous suggestion.

    “Engineering-appropriate prudence?”   “Feechur?”   “Unnecessary complication?”   Only the OP (and his business case) can know for sure.   And, I think, from an engineering point of view, both opinions stand.

      Sure there are many questions linked to version control and related issues, it is worth bringing them up, I had just the feeling that most answers were not really answering the question. But as I said, it may be me who misunderstood the initial question.
      Je suis Charlie.