#!/usr/bin/perl -w open( PH, "customers.txt" ) or die "Cannot open customers.txt: $!\n"; while () { chomp; ( $customer, $number, $email ) = ( split( /\s/, $_ ) ) [0,1,2]; $Customer{$customer} = $_; $Phone{$number} = $_; $Email{$email} = $_; } close(PH); print "Type 'q' to exit\n"; while (1) { print "\nCustomer? "; $customer = ; chomp ($customer); $address = ""; $number = ""; if ( !$customer) { print "E-Mail? "; $address = ; chomp $address; if (! $address) { print "Number? "; $number = ; chomp $number; } } next if ( !$customer and !$address and !$number ); last if ( $customer eq 'q' or $address eq 'q' or $number eq 'q' ); if ( $customer and exists $Customer{$customer} ) { print "Customer: $Customer{$customer}\n"; print "Customer: $Customer{$customer}\n"; next; } if ($address and exists $Email{$address} ) { print "Customer: $Email{$address}\n"; next; } if ($number and exists $Phone{$number} ) { print "Phone: $Phone{$number}\n"; next; } print "Customer record not found. \n"; next; } print "\nAll done.\n";