*IF* that doesn't work--but I think it should--you can go back to your printf() solution.
But just use my variable names, including especially $stat, in place of what you were using.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.