| 1 | # -*- perl -*- | ||
| 2 | |||
| 3 | # | ||
| 4 | # $Id: IxHash.pm,v 1.2 2003/01/16 14:29:10 eserte Exp $ | ||
| 5 | # Author: Slaven Rezic | ||
| 6 | # | ||
| 7 | # Copyright (C) 2002 Slaven Rezic. All rights reserved. | ||
| 8 | # This package is free software; you can redistribute it and/or | ||
| 9 | # modify it under the same terms as Perl itself. | ||
| 10 | # | ||
| 11 | # Mail: slaven@rezic.de | ||
| 12 | # WWW: http://www.rezic.de/eserte/ | ||
| 13 | # | ||
| 14 | |||
| 15 | package WE_Content::IxHash; | ||
| 16 | |||
| 17 | use strict; | ||
| 18 | use vars qw($VERSION @ISA @EXPORT); | ||
| 19 | $VERSION = sprintf("%d.%02d", q$Revision: 1.2 $ =~ /(\d+)\.(\d+)/); | ||
| 20 | |||
| 21 | use Exporter; | ||
| 22 | use Tie::IxHash; | ||
| 23 | @ISA = qw(Exporter Tie::IxHash); | ||
| 24 | |||
| 25 | @EXPORT = qw(OH); | ||
| 26 | |||
| 27 | sub OH { | ||
| 28 | tie my %h, 'WE_Content::IxHash', @_; | ||
| 29 | bless \%h, 'WE_Content::IxHashRef'; | ||
| 30 | } | ||
| 31 | |||
| 32 | sub DD_new { | ||
| 33 | my($self, $name) = @_; | ||
| 34 | Data::Dumper->new([$self], [$name]) | ||
| 35 | ->Toaster('thaw') | ||
| 36 | ->Freezer('freeze') | ||
| 37 | ->Useperl(0) | ||
| 38 | } | ||
| 39 | |||
| 40 | package WE_Content::IxHashRef; | ||
| 41 | |||
| 42 | # for Data::Dumper::Freezer | ||
| 43 | sub freeze { | ||
| 44 | my $ixhashref = shift; | ||
| 45 | bless [ | ||
| 46 | %$ixhashref | ||
| 47 | ], 'WE_Content::IxHashRef::ZZZ'; | ||
| 48 | } | ||
| 49 | |||
| 50 | package WE_Content::IxHashRef::ZZZ; | ||
| 51 | |||
| 52 | # for Data::Dumper::Toaster | ||
| 53 | sub thaw { | ||
| 54 | my $ixhashrefzzz = shift; | ||
| 55 | WE_Content::IxHash::OH(@$ixhashrefzzz); | ||
| 56 | } | ||
| 57 | |||
| 58 | # XXX eventually override Storable and/or Data::Dumper freeze/thaw methods? | ||
| 59 | |||
| 60 | 1; | ||
| 61 | |||
| 62 | __END__ |