Help for this page

Select Code to Download


  1. 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;
    
  2. or download this
    # usage from a so-called sub-script
    use strict;
    ...
    use Constants;
    
    print "Debug: $DEBUG\n";
    
  3. 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 $@;
    
  4. or download this
    package Sharedvariables;
    
    ...
      return $self->{'DEBUG'}
    }
    1;
    
  5. or download this
    # test it
    use strict;
    ...
    print "DEBUG: ".$SVars->debug()."\n";
    $SVars->debug(42);
    print "DEBUG: ".$SVars->debug()."\n";
    
  6. or download this
    package SharedvariablesM;
    
    ...
      return $ret;
    }
    1;
    
  7. or download this
    # and here is a test usage
    use strict;
    ...
    
    my $clone = $SVars->clone();
    print $clone->toString();