in reply to using quotes in hash keys

or simply:
$baseball_team{'Los Angeles'} = 'Dodgers';
You have to place the literal in quotes if it contains white space or other characters that confuse the compiler.

Futher example, these are not the same:

# example 1 $you_never_give_me_any{$money}; # key equals value of $money # example 2 $you_never_give_me_any{'$money'}; # key equals literal string '$mone +y' # example 3 $you_never_give_me_any{"$money"}; # key equals value of $money
Jeff

R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--

Replies are listed 'Best First'.
Re: (jeffa) Re: using quotes in hash keys
by Xxaxx (Monk) on Mar 27, 2001 at 17:39 UTC
    If you'll forgive the some what philosophical bent,.... I find it useful to remind myself on occasion that I'm not actually writing the program. Rather I am creating a set of communications (i.e. commands) which some poor compiler or interpreter is slated to execute. Hence if something is ambiguious it's not surprising that the interpreter burps. Perl is actually one of the most forgiving languages I've had the pleasure to work with. Even my oft-time idiotic code gets the job done. ;-) Claude