"Fossies" - the Fresh Open Source Software Archive

Member "mod_perl-2.0.11/lib/Apache2/PerlSections/Dump.pm" (5 Oct 2019, 2663 Bytes) of package /linux/www/apache_httpd_modules/mod_perl-2.0.11.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Dump.pm" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.0.8_vs_2.0.9.

    1 # please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
    2 # Licensed to the Apache Software Foundation (ASF) under one or more
    3 # contributor license agreements.  See the NOTICE file distributed with
    4 # this work for additional information regarding copyright ownership.
    5 # The ASF licenses this file to You under the Apache License, Version 2.0
    6 # (the "License"); you may not use this file except in compliance with
    7 # the License.  You may obtain a copy of the License at
    8 #
    9 #     http://www.apache.org/licenses/LICENSE-2.0
   10 #
   11 # Unless required by applicable law or agreed to in writing, software
   12 # distributed under the License is distributed on an "AS IS" BASIS,
   13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14 # See the License for the specific language governing permissions and
   15 # limitations under the License.
   16 #
   17 package Apache2::PerlSections::Dump;
   18 
   19 use strict;
   20 use warnings FATAL => 'all';
   21 
   22 our $VERSION = '0.01';
   23 
   24 use Apache2::PerlSections;
   25 our @ISA = qw(Apache2::PerlSections);
   26 
   27 use Data::Dumper;
   28 
   29 # Process all saved packages
   30 sub package     { return shift->saved }
   31 
   32 # We don't want to save anything
   33 sub save        { return }
   34 
   35 # We don't want to post any config to apache, we are dumping
   36 sub post_config { return }
   37 
   38 sub dump {
   39     my $self = shift;
   40     unless (ref $self) {
   41         $self = $self->new;
   42     }
   43     $self->handler();
   44     return join "\n", @{$self->directives}, '1;', '__END__', '';
   45 }
   46 
   47 sub store {
   48     my ($class, $filename) = @_;
   49     require IO::File;
   50 
   51     my $fh = IO::File->new(">$filename") or die "can't open $filename $!\n";
   52 
   53     $fh->print($class->dump);
   54 
   55     $fh->close;
   56 }
   57 
   58 sub dump_array {
   59      my ($self, $name, $entry) = @_;
   60      $self->add_config(Data::Dumper->Dump([$entry], ["*$name"]));
   61 }
   62 
   63 sub dump_hash {
   64     my ($self, $name, $entry) = @_;
   65     for my $elem (sort keys %{$entry}) {
   66         $self->add_config(Data::Dumper->Dump([$entry->{$elem}],
   67                                              ["\$$name"."{'$elem'}"]));
   68     }
   69 
   70 }
   71 
   72 sub dump_entry {
   73     my ($self, $name, $entry) = @_;
   74 
   75     return if not defined $entry;
   76     my $type = ref($entry);
   77 
   78     if ($type eq 'SCALAR') {
   79         $self->add_config(Data::Dumper->Dump([$$entry],[$name]));
   80     }
   81     if ($type eq 'ARRAY') {
   82         $self->dump_array($name,$entry);
   83     }
   84     else {
   85         $self->add_config(Data::Dumper->Dump([$entry],[$name]));
   86     }
   87 }
   88 
   89 sub dump_special {
   90     my ($self, @data) = @_;
   91 
   92     my @dump = grep { defined } @data;
   93     return unless @dump;
   94 
   95     $self->add_config(Data::Dumper->Dump([\@dump],['*'.$self->SPECIAL_NAME]));
   96 }
   97 
   98 
   99 
  100 1;
  101 __END__