| … | |
… | |
| 70 | |
70 | |
| 71 | bless $self, $class; |
71 | bless $self, $class; |
| 72 | return $self; |
72 | return $self; |
| 73 | } |
73 | } |
| 74 | |
74 | |
| 75 | sub hash2string { |
|
|
| 76 | my $hr = shift; |
|
|
| 77 | my $indent = shift || 0; |
|
|
| 78 | my $result; |
|
|
| 79 | foreach (keys %$hr) { |
|
|
| 80 | $result .= "\t"x$indent . "{$_} ="; |
|
|
| 81 | if (ref $hr->{$_} eq 'HASH') { |
|
|
| 82 | $result .= "\n"; |
|
|
| 83 | $result .= hash2string($hr->{$_}, $indent+1); |
|
|
| 84 | } elsif (ref $hr->{$_} eq 'ARRAY') { |
|
|
| 85 | $result .= "\n"; |
|
|
| 86 | $result .= array2string($hr->{$_}, $indent+1); |
|
|
| 87 | } else { |
|
|
| 88 | $result .= " " . $hr->{$_} . "\n"; |
|
|
| 89 | } |
|
|
| 90 | } |
|
|
| 91 | return $result; |
|
|
| 92 | } |
|
|
| 93 | |
|
|
| 94 | sub array2string { |
|
|
| 95 | my $ar = shift; |
|
|
| 96 | my $indent = shift || 0; |
|
|
| 97 | my $result; |
|
|
| 98 | foreach (0 .. @$ar-1) { |
|
|
| 99 | $result .= "\t"x$indent . "[$_] ="; |
|
|
| 100 | if (ref $ar->[$_] eq 'HASH') { |
|
|
| 101 | $result .= "\n"; |
|
|
| 102 | $result .= hash2string($ar->[$_], $indent+1); |
|
|
| 103 | } elsif (ref $ar->[$_] eq 'ARRAY') { |
|
|
| 104 | $result .= "\n"; |
|
|
| 105 | $result .= array2string($ar->[$_], $indent+1); |
|
|
| 106 | } else { |
|
|
| 107 | $result .= " " . $ar->[$_] . "\n"; |
|
|
| 108 | } |
|
|
| 109 | } |
|
|
| 110 | return $result; |
|
|
| 111 | } |
|
|
| 112 | |
|
|
| 113 | 1; |
75 | 1; |