From a6002214271fd33e9c66e8d8b7659756c8917fe9 Mon Sep 17 00:00:00 2001 From: short <> Date: Sun, 28 Aug 2005 05:04:32 +0000 Subject: [PATCH] Support also /_push$/ keys for arrays auto-appends. --- Hash/Sub.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Hash/Sub.pm b/Hash/Sub.pm index 9fa5fd7..cde07be 100644 --- a/Hash/Sub.pm +++ b/Hash/Sub.pm @@ -37,4 +37,15 @@ my($this,$key)=@_; return &{$val}($this,$key); } +sub STORE +{ +my($this,$key,$value)=@_; + + return $this->SUPER::STORE($key,$value) if $key!~/_push$/; + my $val_orig=$this->SUPER::FETCH($key); + $val_orig=[] if !defined $val_orig; + $val_orig=[$val_orig] if "ARRAY" ne ref $val_orig; + return $this->SUPER::STORE($key,[@$val_orig,$value]); +} + 1; -- 1.8.3.1