On Wed, 8 Oct 2014 21:36:06 +0200
Hans Ginzel wrote:
> I want to use one global hash variable for options or configuration
> variables like verbose, debug. I don't want to pass them to each
> function or to almost each object.
package main;
our %Opts = (
verbose => 0,
debug => 0.
);
# yo
On Thu, Oct 09, 2014 at 03:50:02AM +1300, Kent Fredric wrote:
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
On 9 October 2014 08:36, Hans Ginzel wrote:
> I want to use one global hash variable for options or configuration
> variables
> like verbose, debug. I don't want to pass them to each function
> or to almost each object.
>
Indeed, Jim Gibson explains you can simply declare "our" in both files an
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 Oc
ariable 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
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