$dbm_file = "class_dbm"; dbmopen(%class_hash, $dbm_file, 0666) || die "Cannot open $dbm_file: $!"; while (1) { print "Enter all or part of a name (first or last) or '!' to quit: "; chomp($re=); last if $re eq "!"; foreach $key (sort(keys(%class_hash))) { if ($key =~ /$re/i) { printf "%-20s is seated in row %1d\n", $key, $class_hash{$key}; } } }