Does this help?
You were using a numerical comparison operator (!=) to compare strings
and you should use the equivalent string comparison operator (ne).
Here's a highly modified version of teststuff()
------ CODE STARTS ------
sub teststuff()
{
print "\nIn the subroutine...\n";
print '$name=' . $name . "\n";
print '$stuff{$name}=' . $stuff{$name} . "\n";
if ($stuff{$name} ne "Y")
{
print 'We are NOT "Y"' ."\n";
}
else
{
print 'We are "Y"' ."\n";
}
if (defined $stuff{$name} )
{
print "\$stuff{$name} is defined\n";
}
else
{
print "\$stuff{$name} is not defined\n";
}
}
------ CODE ENDS ------
which does what I think you want it to??
Here's how to count the entries in a hash....
------ CODE STARTS ------
#!/usr/bin/perl
%stuff=();
# Populate your hash
%stuff = (
fred => camel,
barney => llama,
betty => alpaca,
wilma => alpaca
);
# Find the number of entries in the hash by using the 'keys' function
# which returns a list of the key=value keys. As it's an ordinary list
# you can evaluate it in a scalar context and get the number of elements
# in the list ie the number of elements n the hash...
$hash_count = (keys (%stuff));
print "We have $hash_count entries in our hash...\n\n";
# And for good measure write them out again...
foreach $key ( keys (%stuff) )
{
print "$key = $stuff{$key}\n";
}
------ CODE ENDS ------
HTH
Steve
------------------------------------------------------------
Steve Logan [EMAIL PROTECTED]
------------------------------------------------------------
--------------------------------------------------------------------
http://www.lug.org.uk http://www.linuxportal.co.uk
http://www.linuxjob.co.uk http://www.linuxshop.co.uk
--------------------------------------------------------------------