Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Problems with Hash Keys and Spaces

by tptass (Sexton)
on Aug 08, 2008 at 16:29 UTC ( [id://703148]=note: print w/replies, xml ) Need Help??


in reply to Problems with Hash Keys and Spaces

How are you defining $variable? I just ran your code with $variable set to "Another generic key" and received 4575 out. See code below:

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

Replies are listed 'Best First'.
Re^2: Problems with Hash Keys and Spaces
by Anonymous Monk on Aug 08, 2008 at 16:33 UTC
     my $variable = "$temp[1]";
      So, What's in $temp[1]?

      Add

      use Data::Dumper;

      Near the top of your program, and

      print Dumper \@temp;

      just before the line with the error


      Unless I state otherwise, all my code runs with strict and warnings
        I can post a small portion of it, only because it's for an internal project.
        $VAR1 = [ '', ', 'Test MMA '/dir/internal_stuff
        There are a few more dirs listed in the array, the 0 spot in the array is empty, 1 contains the info I need and the rest contain directories.
        $VAR1 = [ '', ', 'Test MMA '/dir/k_apps/
        In the array, slot 0 is empty, 1 has the info I want to be matched with the key, and the rest are all component directories. Thanks
      Don't interpolate "$temp[1]". You may be losing information due to interpolation. Try this instead:
      my $variable = $temp[1];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://703148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-26 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found