Hi

could someone point me to a good source where and how the constants Inf and Infinity can be used in Perl?

I tried to define a lazy iteration and I know that I can redefine the constant for my needs

DB<6> $x=0;for (1..Inf) { print; last if $x++ >5} Range iterator outside integer range at (eval 10)[/usr/share/perl/5.10 +/perl5db.pl:638] line 2. DB<7> sub Inf() {1000} DB<8> $x=0;for (1..Inf) { print; last if $x++ >5} 1234567

But I would be interested to know the canonical/intended way to use those constants, before messing around with internals!

Unfortunately grepping thru the perlocs didn't show much information.

It seems to be a feature of Math::BigInt but why can I see the constant without using BigInt???

There are also confusing references to a IEEE 754 standard. In JS a division by zero results to Infinity, but in Perl it's an error?

Please enlighten me about what is happening here...

Cheers Rolf


In reply to Infinity and Inf? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.