in reply to Lose first element of hash in hash ..

Add

use Data::Dumper; print Dumper($th,\%things),"\n";

to your script and enlightenment will follow (probably)

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