/[cvs]/nfo/perl/libs/Hash/Serializer.pm
ViewVC logotype

Contents of /nfo/perl/libs/Hash/Serializer.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Feb 20 21:37:37 2003 UTC (21 years, 8 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
+ refactored code from misc::HashExt

1 ## -------------------------------------------------------------------------
2 ## $Id: Exception.pm,v 1.2 2003/02/20 20:53:55 joko Exp $
3 ## -------------------------------------------------------------------------
4 ## $Log: Exception.pm,v $
5 ## -------------------------------------------------------------------------
6
7
8 package Hash::Serializer;
9
10 use strict;
11 use warnings;
12
13 use overload
14 '""' => \&stringify,
15 ;
16
17 sub new {
18 #print "new: ", __PACKAGE__, "\n";
19 my $class = shift;
20 my $value = shift;
21 #tie(%{$value}, "Tie::IxHash");
22 #return bless \$value => $class;
23 return bless $value => $class;
24 }
25
26 sub stringify {
27 my ($x, $y) = @_;
28
29 # dereference value
30 # TODO: clear this!!!
31 my $value;
32 if ( ref($x) eq 'Hash::Serializer' ) {
33 $value = $x;
34 } else {
35 $value = $$x;
36 }
37
38 my @entries;
39 foreach my $h_key (keys %{$value}) {
40 my $h_val = $value->{$h_key};
41 push @entries, "$h_key: $h_val";
42 }
43 return join " / ", @entries;
44 }
45
46
47 1;
48 __END__

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed