The ‘our’ statement associates a simple name with a package global variable in the current package. Therefore, if you want to make $var in file b.pl mean the package global variable $var in package a ($a:var), just put ‘our $var;’ after the ‘package a;’ statement in file b.pl (see below).
On Oct 8, 2014, at 7:35 AM, Hans Ginzel <h...@matfyz.cz> wrote: > Hello! > > Let's consider following strip-down example: > > # file a.pl > use strict; > package a; > our $var=1; > warn "var=$var"; > > # file b.pl > use strict; > #no strict qw/vars/; > require 'b.pl'; > package a; our $var; > warn "var=$var"; > > How to get rid of "no strict qw/vars/;" to not get message "Global symbol > "$var" requires explicit package name at b.pl", please? There is a package > specification ("package a;") in the b.pl file. > > Generally, I want to add a key to a global class hash variable (%opt) > declared with our in a class module from another file. > > I realised, that there is possible without warning to define a subroutine > in another package, but not to use a global variable from that package > (=namespace). -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/