in reply to hashes with arrays

Depending on what you want to do with the data structure, you might want to build a hash of arrays as others have suggested. If you want to, say, validate makes and models, you might want a hash of hashes. To paraphrase some of what brian_d_foy posted above:
#!/usr/bin/perl use strict; use warnings; my %hash; my $make; while( <DATA> ) { chomp; if( /^(\S.*)/ ) { $make = $1 } elsif( /^\s+(\S.*)/ ) { $hash{$make}{$1} = 1 } elsif( /^\s*$/ ) { next; } } use Data::Dumper; print Dumper( \%hash ); # Valid - prints "Valid..." my ($make1, $model1) = qw(Nissan Maxima); print "Valid $make1 model1\n" if $hash{$make1}{$model1}; # Not valid - doesn't print my ($make2, $model2) = qw(Toyota Mustang); print "Valid $make2 model2\n" if $hash{$make2}{$model2}; # Valid - prints "Valid..." my $make3 = "Ford"; print "Valid $make3\n" if $hash{$make3}; __DATA__ Honda Civic Accord Toyota Camry Corolla Tundra Nissan Maxima
If dealing with makes by themselves is unnecessary, you can even use simulated multilevel hashes (saving some memory if there were a large number of makes and models) by changing this line:
elsif( /^\s+(\S.*)/ ) { $hash{$make}{$1} = 1 }
to this:
elsif( /^\s+(\S.*)/ ) { $hash{$make,$1} = 1 }
And then validate with this:
print "Valid $make1 $model1\n" if $hash{$make1,$model1};