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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |