File: Data_Dumper.pm

package info (click to toggle)
libhtml-template-dumper-perl 0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 192 kB
  • sloc: perl: 247; makefile: 7
file content (63 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
=head1 NAME

HTML::Template::Dumper::Data_Dumper - Output template data using Data::Dumper

=head1 COPYRIGHT

Copyright 2003, American Society of Agronomy. All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the terms of either:

a) the GNU General Public License as published by the Free Software 
Foundation; either version 2, or (at your option) any later version, or

b) the "Artistic License" which comes with Perl.

=cut 


package HTML::Template::Dumper::Data_Dumper;
use strict;
use warnings;
use Data::Dumper;
use base 'HTML::Template::Dumper::Format';

our $VERSION = 0.1;


# 
# Code taken from Data::Serializer::Data::Dumper
# 
sub dump 
{

	my $self = shift;
	my $val = shift || return;
	local $Data::Dumper::Indent = 0;
	local $Data::Dumper::Purity = 1;
	local $Data::Dumper::Terse = 1;
	return Data::Dumper::Dumper($val);
}

sub parse 
{
	my $self = shift;
	my $val  = shift || return;
	my $M = "";
	# Disambiguate hashref (perl may treat it as a block)
	my $N = eval($val =~ /^\{/ ? '+'.$val : $val);
	return $M ? $M : $N unless $@;
	die "HTML::Template::Dumper::Data_Dumper error: $@" . 
		"\twhile evaluating:\n $val";
}

# avoid used only once warnings
{
	local $Data::Dumper::Terse;
}

1;
__END__