...since localtime is getting called again...
Nothing you have shown supports this claim. You've shown a line of code that assigns the result of the localtime() function to the $localtime variable, but not where it exists in the code. So, we have no idea what execution paths may or may not cause that assignment to take place. Ergo, there is no reason for anyone to believe that the $localtime variable ever changes its value.
To me, it sounds like you're doing something like this:
our $foo = 5;
print "foo is $foo\n";
print "foo is $foo\n";
and wondering why it doesn't output
foo is 5
foo is 6
In this example, $foo clearly does not change its value between the two calls to print. Likewise, in your example, it appears that $localtime does not change its value. And this is as it should be because there is nothing magical about a variable named $localtime. You could have named it $foo as I did and you would get the same results.
So ... move the assignment to $localtime such that it's inside your output subroutine and gets executed each time the subroutine is executed, or use one of the many suggestions given in this thread that obviate the need for an extra variable.
duff-washing-his-hands-on-this-thread
|