Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^4: Is 'use vars' really obsolete? (use vars mechanics)

by LanX (Saint)
on Sep 22, 2017 at 12:00 UTC ( [id://1199909]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Is 'use vars' really obsolete?
in thread Is 'use vars' really obsolete?

> I'd say it's globally effective whenever the same package is chosen.

Basically yes.

I had a look into the code of vars and found this discussion Confused by symbol table import mechanism of 'use vars'

What's happening is a "fake" import:

*Target::x = \$Target::x;

Importing means that in the symbol table of the target package a glob is assigned to an external reference.

But in this case it's just a self reference to its own package. (Granted, this looks a bit confusing... *)

Like this strict doesn't complain when seeing an unqualified $var inside package Target because it's already imported into Target's STASH.

To answer the OP, this has global effect while our is tightly scoped.

And the use case you've shown is just a quite complicated way to export.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

*) the symbol table decides which variables, functions, file handles and formats are known to the package without needing to be fully qualified.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-19 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found