Perl Monk, Perl Meditation | |
PerlMonks |
Re^6: Why eval $version?by syphilis (Archbishop) |
on Jul 09, 2020 at 14:03 UTC ( [id://11119084]=note: print w/replies, xml ) | Need Help?? |
our $VERSION = "0.001"; $VERSION = eval $VERSION; The thing I don't like about this is that (depending upon the original string), you might find that, after the eval is done, "$VERSION" ne <original_string> No such problem with "0.001", but consider this simple script: That outputs "WTF". That is, having assigned the string "2.30" to $VERSION, the eval forces $VERSION into a state where it stringifies to something other than "2.30" - namely to "2.3". It's probably of little importance, but I found it annoying enough to immediately replace all occurrences of eval $VERSION in my .pm files with #eval $VERSION I've no regrets about having done that, yet. Notably, with the eval removed, we can then perform both numeric and string comparisons reliably: I find that saner and preferable ... though I now always avoid using version strings that terminate with one or more zeros ... just in case ;-) Cheers, Rob
In Section
Seekers of Perl Wisdom
|
|