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

Re: Re: Scoping Study Aid program

by zeno (Friar)
on Jan 16, 2001 at 14:14 UTC ( [id://52197]=note: print w/replies, xml ) Need Help??


in reply to Re: Scoping Study Aid program
in thread Scoping Study Aid program

I get:
Name "Our_package::my_variable" used only once: possible
typo at scope.pl line 41.
for

print "4) \$Our_package::my_variable NOT DEFINED\n" if not (defined $Our_package::my_variable);
Shouldn't $Our_package::my_variable be something?
I'm looking for a typo but ...

You're right! I get the warning, too, but I let this happen on purpose. This generates a warning because I purposely refer to a variable declared 'my my_variable' in the other package. Since it's declared with 'my', it is (let's see if I get this right) lexically scoped only to the other package, so the calling program can't see it. As I understand it, a variable with lexical scoping means that it only exists within a particular textual area of code, in this case, the package "Our_package". I guess a solution to this would be for me to change the "#!/usr/bin/perl -w" to "#!/usr/bin/perl". Or maybe print a disclaimer about the warning. The point is, the user should learn from this that a 'my' variable in a package is not visible from outside that package.

Log In?
Username:
Password:

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

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

    No recent polls found