Config-ApacheFormat

 view release on metacpan or  search on metacpan

ApacheFormat.pm  view on Meta::CPAN

  $config->inheritance_support(0);
  $config->include_support(1);

=over 4

=cut

use File::Spec;
use Carp           qw(croak);
use Text::Balanced qw(extract_delimited extract_variable);
use Scalar::Util qw(weaken);

# this "placeholder" is used to handle escaped variables (\$)
# if it conflicts with a define in your config file somehow, simply
# override it with "$Config::ApacheFormat::PLACEHOLDER = 'whatever';"
our $PLACEHOLDER = "~PLaCE_h0LDeR_$$~";  

# declare generated methods
use Class::MethodMaker
  new_with_init => "new",
  new_hash_init => "hash_init",

ApacheFormat.pm  view on Meta::CPAN

            croak("Error in config file $filename, line $$line_num: " .
                  "block '<$orig>' is not a valid block name")
              unless not $validate_blocks or
                     exists $valid_blocks{$name};
            
            my $val = [];
            $val = _parse_value_list($values) if $values;

            # create new object for block, inheriting options from
            # this object, with this object set as parent (using
            # weaken() to avoid creating a circular reference that
            # would leak memory)
            my $parent = $self;
            weaken($parent);
            my $block = ref($self)->new(
                  inheritance_support => $self->{inheritance_support},
                  include_support     => $self->{include_support},
                  autoload_support    => $self->{autoload_support},
                  case_sensitive      => $case_sensitive,
                  expand_vars         => $self->{expand_vars},
                  setenv_vars         => $self->{setenv_vars},
                  valid_directives    => $self->{valid_directives},
                  valid_blocks        => $self->{valid_blocks},
                  duplicate_directives=> $self->{duplicate_directives},

t/03leak.t  view on Meta::CPAN


use Config::ApacheFormat;

BEGIN {
    eval {
        require Scalar::Util;
        import  Scalar::Util qw(weaken);
    };
    if ($@) {
        my $mesg = $@;  # $@ cleared on require/import
        require Test::More;
		import  Test::More skip_all => $mesg;
		exit;
	}
}

use Test::More qw(no_plan);

# run this with the call to weaken() in ApacheFormat.pm commented out
# and watch the amazing leaking code in top!  You might need to add
# more iterations if it's buzzing by too fast.
for(0 .. 100) {
    my $config = Config::ApacheFormat->new();
    $config->read("t/block.conf");
    ok(1);
}



( run in 0.766 second using v1.01-cache-2.11-cpan-65fba6d93b7 )