From 8f9131d60ac7fd1e7a9f9da0b143c9d884d0f064 Mon Sep 17 00:00:00 2001 From: vitalif Date: Fri, 10 Apr 2009 22:27:34 +0000 Subject: [PATCH] VMX::Common::hashmrg() --- VMX/Common.pm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/VMX/Common.pm b/VMX/Common.pm index 6c95e37..6497315 100644 --- a/VMX/Common.pm +++ b/VMX/Common.pm @@ -26,7 +26,7 @@ our @EXPORT_OK = qw( HASHARRAY quotequote min max trim htmlspecialchars strip_tags strip_unsafe_tags file_get_contents dbi_hacks ar1el filemd5 mysql_quote updaterow_hashref insertall_hashref deleteall_hashref dumper_no_lf str2time callif urandom - normalize_url utf8on rfrom_to mysql2time mysqllocaltime resub + normalize_url utf8on rfrom_to mysql2time mysqllocaltime resub hashmrg ); our %EXPORT_TAGS = (all => [ @EXPORT_OK ]); @@ -609,5 +609,27 @@ sub resub return $value; } +# недеструктивное объединение хешрефов +sub hashmrg +{ + return undef unless @_; + my $h; + for (@_) + { + if ($_ && %$_) + { + if ($h) + { + $h = { %$h, %$_ }; + } + else + { + $h = $_; + } + } + } + return $h; +} + 1; __END__