Support also /_push$/ keys for arrays auto-appends.
authorshort <>
Sun, 28 Aug 2005 05:04:32 +0000 (05:04 +0000)
committershort <>
Sun, 28 Aug 2005 05:04:32 +0000 (05:04 +0000)
Hash/Sub.pm

index 9fa5fd7..cde07be 100644 (file)
@@ -37,4 +37,15 @@ my($this,$key)=@_;
        return &{$val}($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;