in reply to Problems with Hash Keys and Spaces

Works fine for me. Are you sure $variable has in it what you think it has in it? Where are you getting the value? Have you tried to print it or dump it with Data::Dumper?

my %hash = ( "Common SW Component" => "4885", "Test MMA" => "5130", "Generic key" => "5033", "Another generic key" => "4575", ); my $variable = "Another generic key"; print "$hash{$variable} ($variable)\n"; __END__ 4575 (Another generic key)

Replies are listed 'Best First'.
Re^2: Problems with Hash Keys and Spaces
by Anonymous Monk on Aug 08, 2008 at 16:31 UTC
    Yes, the variable is actually being pulled from an array slot (number 1) and then matched against the key to return the numerical value. If I print the  $array[1] it returns exactly what the key should be, but when i plug it into the previous code I posted I get the error.

      Perhaps you could show us some more of the code you're using. The code you've posted so far doesn't show the problem.