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 Steve Howard other posts by this author
Jul 7 2008 5:28PM messages near this date
view in the new Beta List Site
Re: trouble accessing fully qualified $main::variable contents | RE: trouble accessing fully qualified $main::variable contents
Use "our" instead of "my"

our $var = "value";

Steve

-----Original Message-----
From: perl-win32-users-bounces@[...].com [mailto:perl-win32-users-bounces@[...].com] On Beha
lf Of Greg Aiken
Sent: Monday, July 07, 2008 5:01 PM
To: perl-win32-users@[...].com
Subject: trouble accessing fully qualified $main::variable contents

can anyone please explain why when I am in the subroutine,
and I attempt to print a variable that's been declared and assigned a value
in the main package - why I am unable to print the value of the main
package's variable (despite that I am using the fully qualified variable
name)?

is this my fault or a bug?

it seems to work in some instances, but not work in others...

##########################################

use strict;
use warnings;

my $var = "value";

&subroutine;

sub subroutine {
        print "value of main package's main::var is $main::var\n";
}

############ when above program is run, std out shows ############

C:\perlsrc> test.pl

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.

value of main package's main::var is



_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
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