Code:
#!/usr/bin/perl -w
print $ARGV[0],$ARGV[1];
my $ctr;
for ( $ctr = 0; $ctr < 50000000; $ctr++ ) { print ""; } # just do nothing
while ( 1 ) { print "test2\n"; sleep 1;}
this is just a heavily simplified version of my code, but exhibits the same strange behaviour.
I expect the code to do this:
- immediately print command line parameter 0 and 1
- run the for loop
- print "test2" forever
what happens on the console is this
- first it waits (for loop)
- then it prints $ARGV[0] ....
- then it runs the while loop
if I let it print to STDERR instead of STDOUT it does what I want, except that I don't want it to print to STDERR... I just don't understand what the heck is going on!