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

jethro, thanks for suggesting that .. It produced some interesting output!
'THINGS' => { 'pillow' => 'Nice soft pillow ..', 'sheets' => 'Long white sheets .. You slept +in them last night. ', ' bed' => 'There is some sheets and a pillow here'
The one that is missing, kind of falls out of the print instead of being listed nicely togetehr with the other ones. That datadumper is a pretty useful tool! (I learn so much new here everyday :)

Replies are listed 'Best First'.
Re^3: Lose first element of hash in hash ..
by ikegami (Patriarch) on Mar 11, 2010 at 15:53 UTC
    Setting $Data::Dumper::Useqq = 1; would make it clearer, but the issue is that the key is "\nbed" (newline-b-e-d)
Re^3: Lose first element of hash in hash ..
by jethro (Monsignor) on Mar 11, 2010 at 15:53 UTC
    It seems that the key you are looking for is not stored as 'bed' but as '\nbed'.
      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
      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.