in reply to How to test all elements in a list are hashes?

"are hashes" is not a precise problem description. What about
my @a = bless([], "HASH");
? What about:
{package HASH; use overload "%{}"=>sub{$_[0][0]}} my @a = bless([{}], "HASH");
? The broadest way to tell if something is a hashref is...to see if it's a hashref:
print @$x == grep({eval {\%$_}} @$x),"\n";
All untested.

Replies are listed 'Best First'.
Re^2: How to test all elements in a list are hashes?
by bsdz (Friar) on Jan 17, 2005 at 23:14 UTC
    Well if you're going to bless bananas into apples and overload the task of peeling them, what do you expect! But on the otherhand if you're writing a module and generating and testing your own 'hashes' I don't expect it's a problem. In any case thank you ysth! :-)