On 9 October 2014 03:35, 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; > 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). > > Thank you >
First, what are you trying to acheive. Global variables are rarely a good idea, as is sharing variables between files. So the question is, why are you trying to share a variable between files using globals? My suggestion is you should be using an exporter of some kind, or qualifying the variables by name at very least. Also, why are you *requiring* .pl files by string name? That is reasonably poor design and I would be interested in learning what educational material you are consuming that lead you to your current course of action so I can make a point of not recommending it =) -- Kent *KENTNL* - https://metacpan.org/author/KENTNL