in reply to Re: Requiring a version
in thread Requiring a version

> Are you sure that this code is actually executed when $] reports 5.38.x ?

The linked code is the following:

my $can = eval { require (0 + "$version") }; warn "DEBUG: require $version in $]: ", $can ? 1 : 0;
And the tester's run shows
DEBUG: require 5.040 in 5.038002: 1 at t/02-constructs.t line 346.

Thanks for the heads up about the typo.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^3: Requiring a version
by syphilis (Archbishop) on Jun 19, 2024 at 04:25 UTC
    Hmmm ... one has to really start clutching at straws to come up with an explanation.

    I wondered whether there might be something rendering the "." in "5.040" as garbage (in numeric context) - thereby causing 0 + "$version") to return "5".
    But that should probably generate a "not numeric" warning - and it could (in theory) just as well be a bug in eval{} or require() or the ternary operator.
    I look forward to hearing what the problem was ... if you ever find out.

    Thanks for the heads up about the typo

    You're welcome - I just hope it doens't turn out to be contagious.

    Cheers,
    Rob

      While we are clutching at straws, could 040 be being treated as octal and thus interpreted as 32 decimal?

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond