diff --git a/lib/FormatRenderedProblem.pm b/lib/FormatRenderedProblem.pm index 005b9c2c37..8e128d1bc6 100644 --- a/lib/FormatRenderedProblem.pm +++ b/lib/FormatRenderedProblem.pm @@ -403,20 +403,28 @@ EOS # Nice output for debugging sub pretty_print { my ($r_input, $level) = @_; + return 'undef' unless defined $r_input; + $level //= 4; $level--; - return '' unless $level > 0; # Only print three levels of hashes (safety feature) - my $out = ''; - if (!ref $r_input) { - $out = $r_input if defined $r_input; - $out =~ s/</g; # protect for HTML output - } elsif (eval { %$r_input && 1 }) { - # eval { %$r_input && 1 } will pick up all objectes that can be accessed like a hash and so works better than - # "ref $r_input". Do not use "$r_input" =~ /hash/i" because that will pick up strings containing the word hash, - # and that will cause an error below. - local $^W = 0; - $out .= qq{$r_input
$key | => | " . pretty_print($r_input->{$key}, $level) . " |