in reply to Re^3: Floating point number counting script stuck in a loop
in thread Floating point number counting script stuck in a loop

Huh, I wonder why the tutorial uses (), then? Do they have any purpose or does it just make things look nice, what with all the rounded-off ends? XD

Thanks for that, by the way, I've always wanted to be able to compress scripts to be painfully tiny. (No sarcasm, it really does look impressive).

I did read that variables can be put in strings and I had it that way at the beginning, but I thought it might have been the problem and never changed it back after I tested that.

Thanks for the help.
  • Comment on Re^4: Floating point number counting script stuck in a loop

Replies are listed 'Best First'.
Re^5: Floating point number counting script stuck in a loop
by dwu (Monk) on Oct 25, 2007 at 08:51 UTC
    Tinyish (but most on perlmonks can do better than I):
    #!/usr/bin/perl -w use strict; for (1..9) { print $_/10, "\n"; }
    Does the same as the question asks - likely wouldn't have accomplished the aim of the exercise, which was probably to teach you about using == with floats, but well ;) See perlvar for explanation of $_
      print "0.$_\n" for 1 .. 9;

      ;)


      Perl is environmentally friendly - it saves trees

        GrandFather++; # remind dwu to upvote when she has votes again


        dwu - Amused
      Ha! Nice. Perl golf FTW?
Re^5: Floating point number counting script stuck in a loop
by GrandFather (Saint) on Oct 25, 2007 at 08:48 UTC

    Then you might like:

    #!/user/bin/perl -w use strict; use warnings; print "@{[$_/10]}\n" for 0 .. 9; print "End!\n";

    Perl is environmentally friendly - it saves trees