in reply to Re: Re: Syntactical changes in Perl 5.8 from 5.6.1
in thread Syntactical changes in Perl 5.8 from 5.6.1

Indeed, it interprets an integer as C type "long" or "unsigned long". But %f is a conversion for floats, not integers.

Also, I still don't see anything in the perldelta manpage that either deprecates the "%lf" or mentions that there has been a change in syntax.
It actually might be this:
o The Gconvert macro ($Config{d_Gconvert}) used by perl for stringifying floating-point numbers is now more picky about using sprintf %.*g rules for the conver- sion. Some platforms that used to use gcvt may now resort to the slower sprintf.

But I'm not sure. And not everything is documented, the people working on Perl are only human!

Abigail

Replies are listed 'Best First'.
Re: Re: Syntactical changes in Perl 5.8 from 5.6.1
by sweetblood (Prior) on Oct 10, 2003 at 17:46 UTC
    And not everything is documented, the people working on Perl are only human!

    I've met a couple of them, they are not what I would characterize as human, perhaps super-human.

    Maybe I should elaborate on these scripts. They were conversions from python, and only accept integers and only return integers. They all look similar except for the operator, and are as follows:

    if ($#ARGV != 1) { die "Usage: div numerator denominator\n" } foreach (@ARGV) { die "Integers only\n" if (/\D+/); } my $tot = sprintf "%lf\n", ($ARGV[0]/$ARGV[1]); $tot =~ s/(\d+)(\.\d+)/$1/; print $tot;

    Perhaps someone can suggest a better way. These were very quicky hammered together to fix a problem with some scripts that rely on them after an OS upgarde.
      The last three lines can be written as:
      print int ($ARGV [0] / $ARGV [1]);

      Abigail

        Hi Thanks for your reply.... The reason that I took that approach is that I have several scripts; the div one that you saw in the example but there is also a multiplication script. Since the result could not be expressed in scientific notation I chose to use "%lf" and the use regex to clean it up. This code was used to create the others by just changing the operators. Perhaps not the best method. The multiplication script follows:
        #!/usr/bin/perl -w use strict; if ($#ARGV != 1) { die "Usage: mult integer integer\n" } foreach (@ARGV) { die "Integers only\n" if (/\D+/); } my $tot = sprintf "%lf\n", $ARGV[0] * $ARGV[1]; $tot =~ s/(\d+)(\.0+)/$1/; print $tot;

        If you have any suggestions I'd love to hear them.

        Thanks!