develooper Front page | perl.perl5.porters | Postings from July 2012

Fwd: [perl #113974] package NAMESPACE manpage comments

Thread Next
From:
Linda W
Date:
July 5, 2012 08:36
Subject:
Fwd: [perl #113974] package NAMESPACE manpage comments
Message ID:
4FF5B479.2080502@tlinx.org

Father Chrysostomos via RT wrote:
> I don’t know why.  Perhaps because ‘use vars’ already provides package
> scoping?
>
> In any case, I have actually used ‘our’ to be able to access the same
> variable in different packages in the same file, without having to
> import it into each separate package.  I consider that a feature.
>   
Fair enough, ... ..though sharing a global var between different
packages in the same file -- you admit that in public??  ;-)


and just my luck to use "a" and "b"... (me)-(foot)<-[bang]

BUT... this is a problem:

{       package A;
       use vars qw($aa $bb $cc);
       $aa=1;
       $bb=2;
       $cc=3;
       our ($dd, $ee, $ff);
       $dd=11;
       $ee=22;
       $ff=33;
}
{       package B;
       use vars qw($aa $bb);
       $aa=4;
       $bb=5;
       our ($dd, $ee);
       $dd=44;

}
{       package A;
       print "aa=$aa\n";
       print "bb=$bb\n";
       print "cc=$cc\n";
       print "dd=$dd\n";

}
'

----
'dd' doesn't carry over to future mentions of package A...

and while 'aa/bb' do,

I have this in from 5.10:
NAME
      vars - Perl pragma to predeclare global variable names (obsolete)

SYNOPSIS
          use vars qw($frob @mung %seen);

-------------------


OBSOLETE?!?

What replaces this functionality? as shown above, 'our' doesn't
work.







Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About