Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Why eval $version?

by LanX (Saint)
on Jul 08, 2020 at 23:47 UTC ( [id://11119053]=note: print w/replies, xml ) Need Help??


in reply to Why eval $version?

> Q1) What purpose does this line serve?

the long read: https://xdg.me/blog/version-numbers-should-be-boring/

in short: there are different notations for version numbers which only become comparable after eval.

> Q2) Is this a "string eval?"

yes

> Q4) Does anyone else remember the "that's why we eval version" comment, or is it just me?

Sawyer gave two talks, probably you are confusing them?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Why eval $version?
by syphilis (Archbishop) on Jul 09, 2020 at 00:16 UTC
    there are different notations for version numbers which only become comparable after eval

    Yes, there are some notations that require the eval.
    However, I believe the eval is not needed for comparison when the version string notations are valid floating point numbers (eg "2.31" or "3.20200729").

    Cheers,
    Rob
      One can use _ as delimiter in long literal numbers but not when numifying strings.

      "3.202_007_29"

      Eval treats the string as a literal number.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        One can use _ as delimiter in long literal numbers but not when numifying strings

        Yes- that's pretty much the point I was making.
        However, I wasn't sure if the need to eval comes about solely by introducing an underscore, so I chose to specify the strings that don't require eval rather than the strings that do.
        I had wondered whether eval might also cater for version strings that contain multiple decimal points (v-strings), but a quick check suggests that's not the case. (Someone please let me know if I've got that wrong.)

        Cheers,
        Rob

        ++ on both posts, except why would one group the fractional digits as "3.202_007_29" rather than as "3.2020_07_29", which seems much more intuitive to me?


        Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-04-23 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found