Skip to content
midenok edited this page Jul 14, 2014 · 2 revisions
sub dump
{
    my $c = shift;
    $c->{dump} or return $c;

    my @keys;
    my @dump;
    my %save;
    while ($_ = shift) {
        my $val = shift;
        if (s/^-//) {
            $save{$_} = ${$Data::Dumper::{$_}};
            ${$Data::Dumper::{$_}} = $val;
            next;
        }
        push @keys, $_;
        push @dump, $val;
    }

    $c->{dump}--;
    
    cluck "Dump level $c->{dump}";
    print Data::Dumper->Dump(\@dump, \@keys);
    
    if (!$c->{dump}) {
        exit 0;
    }

    for (keys %save) {
        ${$Data::Dumper::{$_}} = $save{$_};
    }

    return $c;
}
Clone this wiki locally