From: short <> Date: Sun, 28 Aug 2005 05:04:32 +0000 (+0000) Subject: Support also /_push$/ keys for arrays auto-appends. X-Git-Url: http://git.jankratochvil.net/?p=MyWeb.git;a=commitdiff_plain;h=a6002214271fd33e9c66e8d8b7659756c8917fe9;ds=sidebyside Support also /_push$/ keys for arrays auto-appends. --- 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;