Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How does strict determine if something is legally declared? (import)

by tye (Sage)
on Jan 10, 2006 at 16:52 UTC ( #522234=note: print w/replies, xml ) Need Help??


in reply to How does strict determine if something is legally declared?

There's a bit that gets set when you 'import' a variable and this bit tells 'strict' that the variable has been 'declared'. use vars simply 'imports' the variable.

The heuristic that perl uses to detect when a variable is being 'imported' is to detect when the variable slot of a glob gets assigned to by code compiled into another package. Note that the importing has to be done before the code that uses the imported variable is compiled.

> perl -w use strict; BEGIN { *x= \$foo::y; } print $x; Variable "$x" is not imported at - line 3. __END__ Global symbol "$x" requires explicit package name at - line 3. Execution of - aborted due to compilation errors. > perl -w use strict; BEGIN { package foo; *main::x= \$foo::y; } print $x; __END__ Name "foo::y" used only once: possible typo at - line 2. Use of uninitialized value in print at - line 3.

- tye        

  • Comment on Re: How does strict determine if something is legally declared? (import)
  • Download Code

Replies are listed 'Best First'.
Re^2: How does strict determine if something is legally declared? (import)
by haukex (Bishop) on Feb 23, 2019 at 14:24 UTC

      It's a good question. I strongly recommend you post a new SoPW root node.

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
      What? Strict docs or vars docs/source

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2021-08-01 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (13 votes). Check out past polls.

    Notices?