Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][tlug] perl scoping problem
- Date: Wed, 4 Dec 2002 00:09:24 -0800
- From: "Brett Robson" <Brett.Robson@example.com>
- Subject: [tlug] perl scoping problem
Hi all For those that remember me, I've just moved to Tokyo from Nagoya. I've been threating to attend a nomikai for a while now. I've got a problem with Perl namespaces. I haven't used strict and packages before. I thought that variables in main are accessible from with packages. The following code doesn't do what I expect. I expect that $main::foo will have the value robbo. T $cat x.pl #!/usr/bin/perl -w use x1; my $foo; my $bar = "brett"; $foo = "robbo"; print "main\n"; print "foo=".$foo; print "\n"; &x1::set1(); print "back in main\n"; print "foo=", $main::foo; print "\n"; -------------------------------------- $ cat x1.pm package x1; use Exporter; sub set1 { print "set\n"; print "foo=", $main::foo , "\n"; print "foo=", $::foo , "\n"; #print "foo=", $foo , "\n"; print "leaving set\n"; } 1; -------------------------------------- $ ./x.pl main foo=robbo set Use of uninitialized value in print at x1.pm line 7. foo= Use of uninitialized value in print at x1.pm line 8. foo= leaving set back in main Use of uninitialized value in print at ./x.pl line 19. foo= $ --------------------------------------
- Follow-Ups:
- Re: [tlug] perl scoping problem
- From: Matt Doughty
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] DSL through Yahoo BB
- Next by Date: RE: [tlug] perl scoping problem
- Previous by thread: Re: [tlug] DSL through Yahoo BB
- Next by thread: Re: [tlug] perl scoping problem
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links