sanjay nayak has asked for the wisdom of the Perl Monks concerning the following question:
Here is a program to share an variable $f among packages. It works fine.But i want to share an array among packages in this way. So suggest me some code.
package P; use strict; use vars qw($f); # NOTE: *f is a shared typeglob sub foo { print $f,"\n"; $f = "world"; } package main; use strict; use vars qw($f); # NOTE: *f shared with package P *P::f = *f; # make P::f an alias of main::f $f = "howdy"; P::foo(); # after this call, $f is changed! print $f,"\n"; __END__ ouput: howdy world
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Suggest me some code to share an array among packages???
by shmem (Chancellor) on Sep 04, 2006 at 10:48 UTC | |
|
Re: Suggest me some code to share an array among packages???
by gellyfish (Monsignor) on Sep 04, 2006 at 10:11 UTC | |
|
Re: Suggest me some code to share an array among packages???
by TGI (Parson) on Sep 04, 2006 at 20:38 UTC |