#!/usr/bin/perl use strict; use warnings; my %hash; my $make; while( ) { 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 #### elsif( /^\s+(\S.*)/ ) { $hash{$make}{$1} = 1 } #### elsif( /^\s+(\S.*)/ ) { $hash{$make,$1} = 1 } #### print "Valid $make1 $model1\n" if $hash{$make1,$model1};