All pastes #66219 Raw Edit

Someone

public text v1 · immutable
#66219 ·published 2006-06-16 16:28 UTC
rendered paste body
%a = ('a','b');
varType(\%a);

sub varType { # we are supplying a HASH
	local ($var) = @_[$[];	# $var is now a HASH.
	print "ref type is:".ref(\$var);	# "ref type is ref"  #wrong
	print "ref type is:".ref(\%$var); # "ref type is HASH"   #correct
	
	# It only works if I tell ref() that $var is a %hash.
	# But the whole point of the subroutine is that I do not know what the data type is.
	# So how can I find out?
}