How to add elements in a hash in perl?



How to add elements in a hash in perl?..

Answer / Puneet Kumar Kanoujia

In Perl, you can use the '->' operator or the '{}' syntax to add elements to a hash. For example: $hash{'key'} = 'value'. You can also use 'push' on array values if the hash value is an array.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

What is caller function in perl?

1 Answers  


my @array=('data1','data2'); my @array1=('data1','data2'); my ($i,$k); $i=7; $k=7; while($i){ $array [++$#array] = 'ree'; $i--; print "@array"; } while($k){ push(@array1,'ree'); $k--; print "@array1"; } Are these two while loop are doing the same functionality ? What may be the difference?

2 Answers  


What are prefix dereferencer?

1 Answers  


What are the different types of perl operators?

1 Answers  


What are the characteristics of a project that is well suited to Perl?

1 Answers  


Explain goto label?

1 Answers  


What is perl unshift array function?

1 Answers  


Difference between Perl and Mod_perl?

2 Answers  


Explain strftime() function in perl?

1 Answers  


How do I print the entire contents of an array with Perl?

1 Answers  


write a script to display mirror image of a entered value and also check whether Palindrome

3 Answers   HCL, Persistent,


What is subroutine in perl?

1 Answers  


Categories