in reply to Calling functions
The reason this can happen is that the I/O is processed, and then left for the OS to pick up and display. In the mean time, the computer sees no need to just wait around twiddling it thumbs, so it goes on and executes the next line of code. It may very well be able to execute several of lines of code (depending on their complexity/operations) in the time it takes to do a single print statement. But if one of those lines in turn sends something to STDERR, then that could end up getting shunted to the front of the I/O list, because STDERR is given higher priority than STDOUT on most platforms.
So if you have the lines:
print "Hello there\n"; print STDERR "My name is bob\n";
There is no guarantee which line will be printed first. Usually "hello there" will make it to the screen first, but there is no guarantee of that (unless perl does something behind the scenes that I'm not aware of).
And screen I/O is faster than file I/O, so if you've also got output to a file that you're tail -f'ing, that can appear all out of order, too.
Of course, this could all be completely unrelated to your problem, but I hope it helps (or was at least mildly educational).
Some people drink from the fountain of knowledge, others just gargle.
|
|---|