----- Original Message ----- From: "Wiggins d Anconia" <[EMAIL PROTECTED]> To: "Mark Goland" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, September 16, 2004 1:27 PM Subject: Re: HoH not building as expected
> <snip> > > > > > > > > > I expact the output to be > > > > > > > > Unknown =>: > > > > VENDOR :Unknown > > > > CPU-MODEL :model1 > > > > Unknown =>: > > > > VENDOR :Unknown > > > > CPU-MODEL :Unknown > > > > > > I am confused as to why you think you need a HoHoH, when what you > originally displayed above is really a HoAoH because the first 'Unknown' > has multiple entries, which is impossible to replicate with a Hash since > it is a one-to-one relationship, one key to one value. If you still > feel so and are having problems, provide us more of the data and a > larger example of what you expect and we will be able to get it sorted. > Fast access through a hash is good, but correct access even if > requiring a loop is always better than the wrong structure for the data. Hello again my friends, Basicly what I'll have a large set of input data that I need to match against a static list. I want to have following structure Vendor Model Atributes So once I have my HoHoH I can say something like if exists $RATING{Vendor}{Type}{Quntity} and $RATING{Vendor}{Type}{Color} Here is an example with more data... #!PERL use warnings; use strict; my (@te,%RATING,$debug,$attrib,$key,$CPU_ATTR); $debug=0; @te = ( "CREATE CPU-MODEL UNKNOWN_CPU VENDOR Unknown, GENERIC_CPU VENDOR SUN\n" , "Quntity 5\n" , "Color Blue\n" , "CREATE CPU-MODEL model1 VENDOR Unknown, GENERIC_CPU VENDOR Unknown\n", "Quntity 6\n" , "Color Blue\n" , ); s/,|^\t//g for @te; foreach ( @te ){ my $input = $_; my @fields= split /\s+/,$input; print "LINE=$input" if $debug; if( $fields[0] eq 'CREATE' ){ $CPU_ATTR= {}; $RATING{$fields[5]} = $CPU_ATTR;# $CPU_ATTR->{$fields[2]}=$fields[3]; #processor [EMAIL PROTECTED] $CPU_ATTR->{$fields[4]}=$fields[5]; #processor [EMAIL PROTECTED] } if( $fields[0] eq 'Quntity' ){ $CPU_ATTR->{$fields[0]}=$fields[1]; } if( $fields[0] eq 'Color' ){ $CPU_ATTR->{$fields[0]}=$fields[1]; } }# end of while while ( my ($key, $value) = each(%RATING) ) { print "$key =>:\n"; for $attrib ( keys %$value ){ print "$attrib :";print $value->{$attrib} . "\n"; } print "\n\n"; } > > http://danconia.org > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>