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
What is 'commit' command in perl?
Explain subroutine in perl?
What do you mean by context of a subroutine?
What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)
How to read multi lines from a file in perl?
What does localtime() do in perl?
What is perl shift array function?
What are arrays in perl?
What are the arguments and what do they mean in perl programming?
What does the qx{ } operator do?
What are the advantages and disadvantages of perl language?
What does init 5 and init 0 do?
How do you give functions private variables that retain their values between calls?
what is Chop & Chomp function does?
package MYCALC; use Exporter; our @EXPORT = (); our @ISA = qw(Exporter); our @EXPORT_OK = qw(addition multi); our %EXPORT_TAGS = (DEFAULT => [qw(&addition)],Both => [qw(&addition & +multi)]); sub addition { return $_[0] + $_[1]; } sub multi { return $_[0] * $_[1]; } 1; Program: use strict; use warnings; my @list = qw (2 2); use Module qw(:DEFAULT); print addition(@list),"\n"; Above coding is my module MYCALC and the program which using this module, I have not exported any function using @EXPORT, but I have used the DEFAULT in %EXPORT_TAGS with the function addition, when I call this function from the main it says the error as,