[perl #12285] Fix str vs num inf/nan treatment

sprintf, pack and chr were treating 0+"Inf" and "Inf" differently,
even though they have the same string and numeric values.

pack was also croaking for 0+"Inf" passed to a string format.