Answer Posted / prabhath kota
As friends said above, its otherwise called as associative
array. It has lot of advantages over perl.
Here we can keep the values in a structured way, that
structured way comes from key-value pairs.
Eg: (The syntax given above are also correct, but the below
representation is much better in look and feel)
my %hash_example = ( a => 10,
b => 20,
c => 30 );
keys : a,b,c
values : 10,20,30
Features of Hash :
##################
1) Keys should always be unique where as values may not be
unique
(Right)
my %hash_example = ( a => 10,
b => 10,
c => 10 );
(wrong)
my %hash_example = ( a => 10,
a => 20,
a => 30 );
2) keys (%hash_example) will return an array containing only
keys
my @keys = keys(%hash);
3) similary for values
my @values = keys(%values);
Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
List the prefix dereferencer in Perl.
What does a die() function do in perl?
Which of these is a difference between Perl and C++ ?
What is the use of -n and -p options?
Which functions in Perl allows you to include a module file or a module and what is the difference between them?
Is there any way to add two arrays together?
How to create a directory in perl?
Which statement has an initialization, condition check and increment expressions in its body? Write a syntax to use that statement.
What is the difference between perl list and perl array?
I have one question regarding to eval function. I know eval function is use for error checking but I am not able to understand below line. eval \'exec perl -S $0 ${1+\"$@\"}\' if 0; $0 for script name $@ set if error occur
Can inheritance be used in perl?
What is the purpose of goto expr statement?
What are the different string manipulation operators in perl?
You want to download the contents of a url with perl. How would you do that?
Differentiate between use and require, my and local, for and foreach and exec and system