> Hello Wernher, Hi Chris,
> Rob's code could be reconfigured slightly to do so, but requires a > different approach. I will paste it below. Ok, thanks. > One change I made was to make the *values* of %hash1 an array ref as I > thought this was how the hash was originally constructed. If the value > for %hash1 was a string as in Rob's hash, the code below could be > altered slightly to perform the task as well. Ah yes, to make the values of %hash1 an array does make more sense. > You said 'But, I plan to add things like "disk size", "disk size > used" and "disk size free" numeric values next to each partition mount ' > It is good to build up a program in small steps and test as you go, > but it is also helpful to have a large view of the problem so that you > won't create data structures that work for the first stages of the > program but fail to accomodate later alterations. You really kinda > need to have the big picture at the start. You are right, thank you very much. > Chris > > > #!/usr/bin/perl > use strict; > use warnings; > > # I changed the value of the hash to an array (ref). Rob had a string > here > my %hash1 = ( > emcpowera => [qw/sdbd sddg sdfj sdhm/], > emcpoweraa => [qw/sdae sdch sdek sdgn/], > emcpowerbc => [qw/sdb sdbe sddh sdfk/], > emcpowerc => [qw/sdbb sdde sdfh sdhk/], > emcpowerd => [qw/sdba sddd sdfg sdhj/], > emcpowerz => [qw/sdba sddd sdfg sdhj/] > ); > > > my %hash2 = ( > emcpowera1 => "/dwpdb006", > emcpoweraa1 => "/dwpdb033", > emcpowerbc1 => "/s00_11", > emcpowerbc2 => "/utl_file_dir", > emcpowerc1 => "/odsdb006", > emcpowerd1 => "/odsdb005", > ); > > my %seen; > for my $key (sort keys %hash2) { > (my $k1 = $key) =~ s/\d+\z//; > if (my $aref = $hash1{ $k1 }) { > > my $string = "$k1 @$aref"; > $string = ' ' x length($string) if $seen{$k1}++; > > print "$string\t$key $hash2{$key}\n"; > } > } > > delete @hash1{ keys %seen }; > print "$_ @{ $hash1{$_} }\n" for sort keys %hash1; Chris, thank you so very much for this, it does exactly the way I need it!!! I have learned a great deal of things since I joined this list last week Friday the 1st. Kind regards, Wernher Eksteen -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/