Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

[Perl6] Small discoveries I, __DATA__

by holli (Monsignor)
on Sep 27, 2017 at 14:38 UTC ( #1200201=perlmeditation: print w/replies, xml ) Need Help??

Perl6 knows no __DATA__ construct. One can however, use the =finish pod marker and the $=finish variable for similar effect.
use v6; say $=finish; # says "foo" =finish foo
Edit: Renamed as per advice


You can lead your users to water, but alas, you cannot drown them.

Replies are listed 'Best First'.
Re: Small Perl 6 discoveries I, __DATA__
by jahero (Beadle) on Sep 29, 2017 at 07:47 UTC

    I believe that might not be accurate. See this (disclaimer: untested)

    Rats. Should have tried it first.

    ===SORRY!=== Error while compiling c:\temp/test.p6 Pod variable $=data not yet implemented. Sorry. at c:\temp/test.p6:8 ------> say $=data<HERE><Virtues>;

      It says right across the top of the page you linked:
      Note: these documents may be out of date. For Perl 6 documentation see; for specs, see the official test suite.
      I'm going to have to point out that is not always correct either, and let the significance of the last phrase sink in. The test suite is constantly tweaked to match the behavior of the latest perl6 code, so effectively the only specification for Perl6 is perl6 (caps intentional).
Re: Small Perl 6 discoveries II, Rats
by Anonymous Monk on Sep 27, 2017 at 15:09 UTC
    > say 1.111111111111111111111 1.11111111111111111604544
        So the question becomes, why does perl6 print all those wrong digits?
        > perl5 -E 'say 1.111111111111111111111' 1.11111111111111 > perl6 -e 'say 1.111111111111111111111' 1.11111111111111111604544
      If you want arbitrary precision rational arithmetic, you can use a FatRat:
      > say 1.111111111111111111111.FatRat 1.111111111111111111111
        If you want arbitrary precision rational arithmetic, you can use a FatRat

        I didn't know about FatRats (yes, I know very little about perl6) - so I had a bit of a play (on rakudo-star-2017.07) and encountered confusing results:
        > my $x = 1.111111111111111111111.FatRat; my $y = 1.111111111111111111 +111.Rat; $x - $y 0 > $x == $y True > say $x 1.111111111111111111111 > say $y 1.11111111111111111604544 >
        On the bases that $x-$y==0 and $x==$y one is led to believe that $x and $y are exactly equivalent.
        Yet, say() presents us with different values.

        Are the 2 rationals equivalent ?
        If so, then why does say() output different values ?
        If not, then why do both $x-$y==0 and $x==$y evaluate as "True" ?

        Interestingly, 1.11111111111111111604544 is the value of the double 1.1111111111111111 (16 decimal places) rounded to 23 decimals:
        C:\>perl -le "printf '%.22e\n', 1.1111111111111111;" 1.1111111111111111604544e+000\n
        Perhaps this ties in with:
        > my $x = 1.111111111111111111111.FatRat; my $y = 1.1111111111111111.N +um; $x - $y 0 > $x == $y True
        How does one coerce perl6 into displaying the actual numerator and denominator of these rationals ?

        If the Rat class isn't any more accurate than a Num, but it's much slower, then what purpose does it serve?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1200201]
Approved by haukex
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-10-21 02:05 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (269 votes). Check out past polls.