Doraemon has asked for the wisdom of the Perl Monks concerning the following question:
I wonder, how to prevent (control) hashes members?
Let say
One way i can think of is to define the keys in constants,
Let say
How to avoid this (silly) mistake?my %hash; $hash{'name'} = "Doraemon"; $hash{'age'} = "1000"; #... some code # oh! my birthday, i'm getting older $hash{'ege'} = "1001"; # oops, i just add new key
One way i can think of is to define the keys in constants,
so the compiler can catch the mistake, when use strict. Any more 'efficient' ideas?$k_name = 'name'; $k_age = 'age'; $hash{$k_ege} = "Do"; # warning, gotcha!
Back to
Seekers of Perl Wisdom