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

Re: Bug in Module::Info? our vs. use vars (local our)

by Anonymous Monk
on Jan 16, 2016 at 08:22 UTC ( [id://1152919]=note: print w/replies, xml ) Need Help??


in reply to Bug in Module::Info? our vs. use vars

update: local our works

my $eval =<<'END_EVAL'; no strict; local our $VERSION; $VERSION=undef; do { $VERSION = 'desired_version'; }; $VERSION END_EVAL

I think its like doing  my $foo; { my $foo; } the inner foo is invisible

Maybe see 'our' is not 'my' , local our $var; What does it do?

Replies are listed 'Best First'.
Re^2: Bug in Module::Info? our vs. use vars (local our)
by Athanasius (Archbishop) on Jan 16, 2016 at 09:05 UTC
    local our works

    Yes, it works without warnings provided there is no our inside the do block. But that our comes from the external module being examined (Capture::Tiny in my examples), and when that our is present a warning is generated:

    18:47 >perl 1513_SoPW.pl "our" variable $VERSION redeclared at (eval 1) line 4. (Did you mean "local" instead of "our"?) Version: desired_version 18:47 >p5u v Capture::Tiny Capture::Tiny "our" variable $VERSION redeclared at (eval 49) line 7, <MOD> line 6. (Did you mean "local" instead of "our"?) C:\Perl\Strawberry\strawberry-perl-5.22.1.1-64bit-PDL\perl\ven +dor\lib\Capture\Tiny.pm: 0.30 18:47 >

    Thanks for the links. I’ve read 'our' is not 'my'; local our $var; What does it do? is interesting, but local our wouldn’t be suitable as a patch, anyway, because (judging by the use 5.006 pragma) Module::Info is intended to be backwards-compatible as far back as Perl 5.6.

    Cheers,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      :) solution is simple, eliminate any "our", don't do "our" in inner blocks of eval, our $VERSION; local $VERSION; is adequate, you don't have to use local our $VERSION;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found