ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
Re: trouble accessing fully qualified $main::variable contents
by Andy Bach other posts by this author
Jul 7 2008 5:46PM messages near this date
view in the new Beta List Site
trouble accessing fully qualified $main::variable contents | Re: trouble accessing fully qualified $main::variable contents
>  why I am unable to print the value of the main
package's variable (despite that I am using the fully qualified variable
name)?

Name "main::var" used only once: possible typo at C:\perlsrc\TEST.PL line
9.

Use of uninitialized value in concatenation (.) or string at
c:\perlsrc\TEST.PL line 9.


Hmm, this:
use strict;
use warnings;

our $var = "value";

works as expected. 'my' is the lexicalizer, so it appears it *doesn't* put
the var into the main package. Something like lexical vars *can't* be
package scope/FQVNamed, only 'our' vars can. Try 'perldoc our':
               An "our" declares the listed variables to be valid globals
within the enclosing block, file, or "eval".  That is, it has the same
scoping rules
as a "my" declaration, but does not create a local variable.  If more than
one value is listed, the list must be placed in parentheses.  The "our"
declaration has no semantic effect unless "use strict vars" is in effect,
in which case it lets you use the declared global variable without
qualifying it with a package name.  (
But only within the lexical scope of the "our" declaration.  In this it
differs from "use vars", which is package scoped.)

               An "our" declaration declares a global variable that will be
visible across its entire lexical scope, even across package boundaries.
The package in which the variable is entered is determined at the point of
the declaration, not at the point of use.  This means the following
behavior holds:

a

-------------------
Andy Bach
Systems Mangler
Internet: andy_bach@[...].gov
Voice: (608) 261-5738 Fax: 264-5932

The name "grep" is from the common "ed" (pre-visual "vi") command:
 g/re/p i.e. g(lobal-search)/r(egular) e(xpression)/p(rint)

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Greg Aiken
Andy Bach
Ben Bullock
Steve Howard
Jan Dubois

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved