to have e.g. $# restored at the end of a block.{ local $#; ... do some stuff }
To force something to stringize as a number, first convert it with the 0+ operator and then use it in a string context:$x = "0."; $x = 0+ $x; print $x; Just kidding, there is no 0+ operator; but simply adding 0 as above will produce something with a numeric value and no string value; then using it in string context will cause the numeric value to be stringized, invoking $# (unless the newish preserve-integers-where possible logic kicks in).
By the way, $# is deprecated; use printf/sprintf directly instead; that will save you having to do the conversion: $x = "0."; printf "%.15e", $x and will avoid the aforementioned problem with perl bypassing floating point.
In reply to Re: restoring special variable defaults
by ysth
in thread restoring special variable defaults
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |