Hash hash overwrites : Hash Assignment « Hash « Perl






Hash hash overwrites

    

#!/usr/bin/perl
use strict;
use warnings;

my %default_animals = (Cat => 'Tom', Mouse => 'Jerry');
my %input_animals = (Cat => 'Ginger', Mouse => 'Jerry');

my %animals = (%default_animals, %input_animals);
print "$animals{Cat}\n"; # prints 'Ginger'

   
    
    
    
  








Related examples in the same category

1.Hashes Assignment in action
2.Merge two hash variable
3.Hash List Assignment