in reply to printf in if-statement

Without a small sample of your input file, it is not simple to reproduce your results. Try to print both values before your "if" line:
print "julday >>>$julday<<<\n"; print "julday_old >>>$julday_old<<<\n";

Are these values integers, or are they floating point values?

Isn't...

if(! ($julday == $julday_old)){

the same as...?

if ($julday != $julday_old){