in reply to Re^2: Lose first element of hash in hash ..
in thread Lose first element of hash in hash ..

It seems that the key you are looking for is not stored as 'bed' but as '\nbed'.
  • Comment on Re^3: Lose first element of hash in hash ..

Replies are listed 'Best First'.
Re^4: Lose first element of hash in hash ..
by theantler (Beadle) on Mar 11, 2010 at 16:14 UTC
    ikegami, jethro, thanks for your kind help. Ok, that is pretty crazy but it makes sense, and I suspected something along those lines (that it is stored as \nbed instead of bed. But how can it? It is read from a text file composed in vi that reads:
    bed-There is some sheets and a pillow here-pillow-Nice soft pillow ..- +sheets-Long white sheets .. You slept in them last night.
    I dont know where the \n comes from. I would suspect that the \n would terminate the line (from a CR) not initiate it. ta

      Well, if you do

      cat rooms.txt

      what do you see?

      > cat rooms.txt bed-There is ...

      or

      > cat rooms.txt bed-There is ...

      If you see the second variant, then you have a \n at the start of your file. Maybe you should read the file line by line, or sanitize your input.

Re^4: Lose first element of hash in hash ..
by theantler (Beadle) on Mar 11, 2010 at 18:12 UTC
    jethro, when I cat the text I get no \n except at the end of lines. I just did  $_ =~ s/\n//g; and that got rid of the problem, I guess that is a way of sanitizing input? Thanks, ta