This applies to all OSes, even (tho' it pains me greatly to say it) Windoze - every Windoze host has a C: drive, which, in this context, can be taken to be the equivalent of a volume name.
IMO. the question (to ask of annie06) ought to be: 'Are all volumes the same size on every host?'
My reading of the OP suggests that where ever i.e. on which ever host, vol2 exists, it is always 20g, so a simplified version of the lookup table based approach (similar to that outlined by kennethk) should suffice - something along the lines of i.e. untested ...
use warnings; use strict; use autodie; #for each vol_size_entry in the volsize file do # add the vol_size_entry to the volsize lookup (keyed on vol name) #done open FILE, "<volsize"; my %volsize = map { local @_ = split; # $_[1] needs normalising (to chosen common units) and removal of +unit spec /_name/ ? () : ($_[0] => $_[1]); } <FILE>; close FILE; #for each host_entry do # lookup the size of the vol for the host # add the vol size to the record for the host #done open FILE, "<hostfile"; my %hostsize; while (<FILE>) { next if /_name/; local @_ = split; $hostsize{$_[1]} += $volsize{$_[0]}; } close FILE;
In reply to Re^4: hashes with multiple keys
by Bloodnok
in thread hashes with multiple keys
by annie06
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |