Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: use strict and exporting package variables

by satchboost (Scribe)
on May 01, 2001 at 02:18 UTC ( [id://76791]=note: print w/replies, xml ) Need Help??


in reply to use strict and exporting package variables

One thing I do (which I feel is just sane design, let alone working with Exporter and use strict) is the following:

package Foo; use Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw(access_internal_var); use strict; my %Internal_Var_Here; sub access_internal_var { # Insert code here to access the hash }

Now, in Perl5.6, you get the our keyword. That would modify the above as such:

use strict; package Foo; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(access_internal_var); . . .

The reason I say that this is sane design is that this acts as encapsulation of global variables in a very local way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-24 11:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found