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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.