What do you mean by "not working"? It works quite fine for me.
use Data::Dumper; print Dumper \%hash_mnt; __END__ $VAR1 = { '/proc/bus/usb' => [ ['usbfs'], [undef] ], '/sys' => [ ['none'], [undef] ], '/' => [ ['/dev/hda1'], [undef] ], '/dev/pts' => [ ['none'], [undef] ], '/tmp' => [ ['/dev/hda5'], [undef] ], '/proc' => [ ['proc'], [undef] ], '/home' => [ ['/dev/hda6'], [undef] ] };
Do you mean that this structure is not what you wanted? It seems most sensible that you'd want a hash of arrays instead of the hash of arrays of arrays. Maybe like so?
foreach $mount(@Mounts){ ($mnt_key,$mnt_val,$mnt_acc)=(split(/\s+/,$mount))[2,0,6]; $hash_mnt{$mnt_key} = [ mnt_val, $mnt_acc ]; } use Data::Dumper; print Dumper \%hash_mnt; __END__ $VAR1 = { '/proc/bus/usb' => [ 'usbfs', undef ], '/sys' => [ 'none', undef ], '/' => [ '/dev/hda1', undef ], '/dev/pts' => [ 'none', undef ], '/tmp' => [ '/dev/hda5', undef ], '/proc' => [ 'proc', undef ], '/home' => [ '/dev/hda6', undef ] };
Makeshifts last the longest.
In reply to Re: Dynamic creation of hashes
by Aristotle
in thread Dynamic creation of hashes
by shamala
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |