[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: [PATCH lib/lib.pm 5.005_63] Removing use of vars.pm



On Sat, 22 Jan 2000 21:40:31 EST, Michael G Schwern wrote:
>I believe he's refering to this possiblity:
>
>package Foo;  
>use vars qw($this);
>$this = "Foo";
>
>package Bar;
>use vars qw($this);
>$this = "Bar";
>
>package main;
>print $Foo::this;
>
>That's fine.  But if you robotically replace "use vars" with "our":
>
>package Foo;
>our $this = "Foo";
>
>package Bar;
>our $this = "Bar";
>
>package main;
>print $Foo::this; 
>
>You wind up with a lexical scoping problem:
>
>"our" variable $this masks earlier declaration in same scope at -e line 1.
>Name "Bar::this" used only once: possible typo at -e line 1.
>Foo

This won't be the case in v5.5.640.  See change#4801, which I sent
here.

>I'll watch for this possibility and leave files with multiple package
>definitions alone.

No real reason to.  A mechanical replacement should "just work", unless
you have multiple "use vars" declarations for the same variable in the
same package in the same file (in which case the warning will probably
help identify what might be a potential typo).


Sarathy
gsar@ActiveState.com


References to:
Michael G Schwern <schwern@pobox.com>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]