Hi All,
      I am trying to build a HoH, who's keys will be referances to products. However 
it seems if $e [ vendor value] is the same, the hash get's recreated instead of 
appending a product to already existing hash. Any ideas would be apreciated,

#!PERl -w
use warnings;
use strict;
use String::Scanf;

my (@te,$a, $b, $c, $d, $e,%RATING,$CPU_ATTR,$debug,$attrib,$key);

my $s1 = String::Scanf->new("%s %s %s %s %s"); #define string template


@te = (   "CREATE         CPU-MODEL UNKNOWN_CPU VENDOR Unknown, GENERIC_CPU VENDOR 
SUN\n" ,
          "CREATE         CPU-MODEL model1 VENDOR Unknown, GENERIC_CPU VENDOR 
Unknown\n" );

s/,|\t//g for @te;


foreach ( @te ){

print "LINE=$_" if $debug;

 
($a, $b, $c, $d, $e) = $s1->sscanf();

if( $a eq 'CREATE' ){
        $CPU_ATTR= {};
        $RATING{"$e"} = $CPU_ATTR;# main key is Vendor hashref to CPU_ATTR
        $CPU_ATTR->{$b}=$c; #processor [EMAIL PROTECTED]
        $CPU_ATTR->{$d}=$e; #processor [EMAIL PROTECTED]
}

}

while ( my ($key, $value) = each(%RATING) ) {
        print "$key =>:\n";
        for $attrib ( keys %$value ){
                print "$attrib :";print $value->{$attrib} . "\n";
        }
print "\n\n";
}

I expact the output to be 

Unknown =>:
VENDOR :Unknown
CPU-MODEL :model1
Unknown =>:
VENDOR :Unknown
CPU-MODEL :Unknown  


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to