in reply to Re: print hash of hashes with a reference
in thread print hash of hashes with a reference

Sorry, here's the output of Dumper:
$VAR1 = { '4' => { 'group ' => ' 3 ', 'user ' => ' root ', 'host ' => ' 10.0.200.181 ', 'cmd ' => ' ls -l / ' }, '1' => { 'cmd ' => ' md5sum /vmlinuz ', 'group ' => ' 1 ', 'user ' => ' root ', 'host ' => ' 10.0.200.181 ' }, '3' => { 'group ' => ' 1 ', 'user ' => ' root ', 'host ' => ' 10.0.200.183 ', 'cmd ' => ' ls -l / ' }, '2' => { 'group ' => ' 2 ', 'user ' => ' root ', 'host ' => ' 10.0.200.184 ', 'cmd ' => ' ls -l / ' } }; 1. Use of uninitialized value in concatenation (.) or string at ./master- +backup-daemon.pl line 245. Host = 2. Use of uninitialized value in concatenation (.) or string at ./master- +backup-daemon.pl line 245. Host = 3. Use of uninitialized value in concatenation (.) or string at ./master- +backup-daemon.pl line 245. Host = 4. Use of uninitialized value in concatenation (.) or string at ./master- +backup-daemon.pl line 245. Host =
I'd like to print values from the hashes, but somehow the way i want to extract the values from the hashes doesn't seem to work. Line 245 is the line where the print command is.

Replies are listed 'Best First'.
Re^3: print hash of hashes with a reference
by toolic (Bishop) on Aug 16, 2008 at 21:19 UTC
    It looks like you have spaces after the "cmd" string. So, your keys are not really "cmd", they are "cmd ". I can't really tell how many spaces you have in those keys.
Re^3: print hash of hashes with a reference
by FunkyMonk (Bishop) on Aug 16, 2008 at 21:19 UTC
    Look at your Data::Dumper output. You've got a space or tab after each of your keys.
Re^3: print hash of hashes with a reference
by shmem (Chancellor) on Aug 16, 2008 at 21:28 UTC
    'cmd ' => ' ls -l / '

    Looks like your keys contain trailing whitespace, and your values have a leading blank and a trailing newline.

    -- shmem
Re^3: print hash of hashes with a reference
by broomduster (Priest) on Aug 16, 2008 at 21:24 UTC
    Notice that the second level keys have whitespace at the end, and notice that your print statement uses a key of cmd (no whitespace). You should trim the whitespace when you construct the hash.

    You should also take notice here that the values have \n (and possibly other whitespace) at the end (which may also bite you, depending on how you intend to use them).

Re^3: print hash of hashes with a reference
by ScOut3R (Sexton) on Aug 16, 2008 at 21:51 UTC
    Thank You! All of You! The spaces were the problem. It's a shame that i haven't noticed this myself.