http://qs321.pair.com?node_id=815653


in reply to Re: eval $VERSION in modules?
in thread eval $VERSION in modules?

But that's only useful if you don't control the assignment of $VERSION itself (like $ExtUtils::MakeMaker::VERSION). If you want to put a numerical value in a variable, then:
our $var = 'string looking like a number'; $var = eval $var;
is not the way to earn brownie points. Suggest that during a job interview with me, and I won't recommend to my boss to hire you. You want a number inside your variable? Omit the quotes, don't use eval:
our $VERSION = 0.08;

Replies are listed 'Best First'.
Re^3: eval $VERSION in modules?
by JadeNB (Chaplain) on Jan 04, 2010 at 22:39 UTC

    I was ignorantly cut-and-pasting; thanks for clarifying why the idiom is useful for ExtUtils::MakeMaker but not for most uses.

    I considered mentioning the quotes, but didn't, because I thought that Perl determined the ‘purpose’ of a scalar when it was used, not when it was created. As you point out, I was wrong:

    $ perl -MDevel::Peek -e 'Dump "0.08"; Dump 0.08' SV = PV(0x80306c) at 0x800cc0 REFCNT = 1 FLAGS = (POK,READONLY,pPOK) PV = 0x205700 "0.08"\0 CUR = 4 LEN = 8 SV = NV(0x812e00) at 0x800c6c REFCNT = 1 FLAGS = (NOK,READONLY,pNOK) NV = 0.08