I often see examples of straight values (excluding single & double quotes) as keys for hashes and most recenlty saw in Advanced Perl Programming, ex 2-3 (p 30) of
$curr_prof->{Office Hours} = interval_parse($1);
I receive an error when I try and test the code: Can't locate object method "Office" via package "Hours". At first I thought it must be an error that Sriram left out the quotes, but I could not find it in the
errata I always use quotes or string variables as keys and will continue to do so, but is the above code an error or not?
Further testing:
$baseball_team{Seattle} = "Mariners";
okay!
$baseball_team{Los Angeles} = "Dodgers";
error!
$la = "Los Angeles";
$baseball_team{$la} = "Dodgers";
okay!