Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: How Critical is Critic?

by eyepopslikeamosquito (Archbishop)
on May 29, 2023 at 21:42 UTC ( [id://11152481]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How Critical is Critic?
in thread How Critical is Critic?

The answer would be because I understand that is what I am supposed to do because Perl uses underscores in the version number to indicate a development release. This release is currently a development release 0.1_1 with an underscore.

Good answer!

I strongly suspect that it was you eyepopslikeamosquito who directed me towards this practice as you were the one who helpfully provided the information I needed to publish my first module

Yes Bod, I believe you are correct.

The version numbers should be boring link you mentioned by David Golden is indeed listed at Software Versioning links ... which is listed at Writing Solid CPAN Modules.

Update: Re: What do I use to release a module to CPAN for the first time? by davido similarly endorses $VERSION = eval $VERSION ... as do the official Perl docs perlmodstyle (in the Version numbering sub-section). Thanks Bod.

I would conclude our code review meeting by reaching for a towel to wipe the egg off my face. :)

Replies are listed 'Best First'.
Re^4: How Critical is Critic?
by Bod (Parson) on May 29, 2023 at 22:20 UTC
    I would conclude our code review meeting by reaching for a towel to wipe the egg off my face. :)

    ...and I would ensure you save face by asking for your expert opinion on what you would do if you were me when this situation recurs...

    Which of these do you suggest I use and why? I am not entirely sure of the practical differences.

    our $VERSION = '0.1_1'; $VERSION = eval $VERSION;
    or perhaps
    our $VERSION = '0.1_1'; $VERSION = eval { $VERSION };
    or maybe
    use version; our $VERSION = version->parse('0.1_1');
    or something else entirely...

    I believe that eval { ... }; is compiled just once whereas eval ...; is compiled each time the module is instantiated. This may make a difference if the module is created for each use like MIME::Lite. However, this module should only be created once and subsequent method calls achieve everything it does.

    I don't see the point in fetching in the version module (even though it is core) to do something that can be done in two lines of simple code. Perhaps it does something more that I'm not aware of?

      The reasonable version of this idiom is:
      our $VERSION = '0.1_1'; $VERSION =~ tr/_//d;
      % perl -wle ' our $VERSION = "0.1_1"; $VERSION = eval $VERSION; if ($VERSION > 0.1 && $VERSION < 0.2) { print "ok"; } else { print "not ok"; } ' ok % perl -wle ' our $VERSION = "0.1_1"; $VERSION = eval { $VERSION }; if ($VERSION > 0.1 && $VERSION < 0.2) { print "ok"; } else { print "not ok"; } ' Argument "0.1_1" isn't numeric in numeric gt (>) at -e line 4. not ok %

      eval STRING and eval BLOCK do different things. In this case the BLOCK form is effectively a no-op, so the string is numified using standard coercion during the comparison, and yields the value 0.1 (plus a warning). The string form means "take this string and interpret it as a program" - and Perl code lets us put underscores in numbers, even though the standard coercion rejects them, so it evaluates as the value 0.11.

      I don't know about the version->parse variant, but I imagine that PAUSE would not find a version number to parse, so the module would not be indexed correctly.

Re^4: How Critical is Critic?
by Bod (Parson) on May 29, 2023 at 22:27 UTC
Re^4: How Critical is Critic?
by Bod (Parson) on May 30, 2023 at 11:22 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-28 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found