in reply to update a hash with a hash
hope it solves your problem.#!/usr/bin/perl my %hash1 = ( key1 => val1, key2 => val2, key3 => val3, key4 => val4, key5 => val5); my %hash2 = ( key1 => xxxval1, key2 => xxxval2); out:foreach my $key (keys %hash1) { foreach my $inkey (keys %hash2) { if($key eq $inkey) { $hash1{$key} = $hash2{$inkey}; next out; } } }
janitored by ybiC: Balanced <code> tags around codeblock
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: update a hash with a hash
by beable (Friar) on Jul 15, 2004 at 10:11 UTC |