#!/usr/bin/perl -w

# Search for an element in a hash

use Hash;

$h = new Hash('NUMSLOTS' => '19', 'DEBUG' => '1');

# Generating 100 integers
$NUM = 100;
$MAXINT = 5000;

srand();

print "Numbers Generated:\n(";
for $i (1 .. $NUM) {
	$valueToInsert = sprintf("%d", rand(1) * $MAXINT);
	$h->add($valueToInsert, 0);	# in fact, any values can be assigned here
	print $valueToInsert;
	print ", " unless ($i == $NUM);
}
print ")\n\n";

print "Slot utilization: ", $h->getUtilization(), "\n\n";

print "Please enter the number to search for >> ";
chomp($toSearch = <STDIN>);

# Hash search here
if ($h->exists($toSearch)) {
	print "\"$toSearch\" found!\n";
} else {
	print "\"$toSearch\" not found!\n";
}
