perl: print a string from a hash that contains a reference to it

Viewed 1263

Sorry if this is a bad title.

I have the following hash:

my %map = (
    'key1', 'hello',
    'key2', \'there'
);
print Dumper(\%map);

output:

$VAR1 = {
    'key2' => \'there',
    'key1' => 'hello'
};

I want to print out the value at 'key2'. Here's what I've tried:

print "$map{key2}" => SCALAR(0x2398b08)
print "$$map{key2}" =>
print "$map->{key2}" =>

my goal:

print [some magic thing] => there

I'm new to perl, so I'm not 100% clear yet on how references behave and how to dereference them. How do I get what I'm looking for?

3 Answers
Related