Perl Basics   «Prev  Next»

Perl hash function - Exercise

Working with hash function in Perl

Using this hash reference definition, answer the following questions:
$hashref = { 
	FOO => 'bar', 
	BAZ => 'boz', 
	COUPLES => { 
		'fred' => 'wilma',
		'samson' => 'delilah',
	},
	OTHERS => {
		'calvin' => 'hobbes',
		'tom' => 'jerry',
	},
};

1. What is the result of the following expression?
$hashref->{COUPLES}{samson} 

2. Write a loop to list the hash referenced by OTHERS.