- or download this
# package to group all constant, read-only vars like $DEBUG
# file is Constants.pm and can be placed in same dir as main script
...
our $CON2 = 'another constant';
our $DEBUG = 1;
1;
- or download this
# usage from a so-called sub-script
use strict;
...
use Constants;
print "Debug: $DEBUG\n";
- or download this
# test.pl to demo the whole setup
# run as perl -I. test.pl
...
use warnings;
do 'lib/subscript.pl';
die "failed $@" if $@;
- or download this
package Sharedvariables;
...
return $self->{'DEBUG'}
}
1;
- or download this
# test it
use strict;
...
print "DEBUG: ".$SVars->debug()."\n";
$SVars->debug(42);
print "DEBUG: ".$SVars->debug()."\n";
- or download this
package SharedvariablesM;
...
return $ret;
}
1;
- or download this
# and here is a test usage
use strict;
...
my $clone = $SVars->clone();
print $clone->toString();