Before it was removed, the docs say it was:

The output format for printed numbers. This variable is a half-hearted
attempt to emulate awk's OFMT variable. There are times, however, when awk
and Perl have differing notions of what counts as numeric. The initial
value is "%.ng", where n is the value of the macro DBL_DIG from your
system's float.h. This is different from awk's default OFMT setting of
"%.6g", so you need to set $# explicitly to get awk's value. (Mnemonic: #
is the number sign.)

So, you can probably get away with

printf "%.15g\n", $var;

You can find the exact value of DBL_DIG on your system with the following C
code:

#include <stdio.h>
#include <float.h>

int main(int argc, char** argv) {
        printf("%d\n", DBL_DIG);
        return 0;
}

Just put that in a file named dbl_dig.c and run

cc dbl_dig.c -o dbl_dig

and then run it:

./dbl_dig



On Fri, Jan 26, 2018 at 4:36 PM Peng Yu <pengyu...@gmail.com> wrote:

> Hi, $# is deprecated. Could anybody let me know what is the substitute for
> it?
>
> https://perldoc.perl.org/perlvar.html
>
> $# was a variable that could be used to format printed numbers. After
> a deprecation cycle, its magic was removed in Perl v5.10.0 and using
> it now triggers a warning: $# is no longer supported.
>
> --
> Regards,
> Peng
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to