OK, you're saying that if the object overloads stringify, then you won't get the normal string for the hash or array.
Right. Also if it overloads numericification. (Which is worse since there isnt a overload::numval)
But what does parsing the StrVal left of the = sign do that ref() doesn't?
Im not sure where the "left" part comes from. I did a regex to check if an '=' was in the name only to determine that the first parameter passed to the callers sub was indeed a blessed reference. This is a good first step, but it isnt an exhaustive check as it has no way to determine that the following are different
foo($obj);
$obj->foo();
If caller had a flag to say that the sub was invioked via a method then this would be a much better way to do this.
Anyway, coming back to parsing.. The result of overload::StrVal() gives three things: Base Type*, memory location/unique identifier, Class type.
Ref gives you the first if the reference isnt blessed and the class name if it is. That isnt particularly useful (in my experience) as you more often than not want to check type to see how the object should be dereferenced. Also Base Type has a star next to it because it isnt really base type. For instance a reference to a scalar value can return no less than three completely different things: Ref, Scalar and Glob. While apparently weird it is useful behaviour though. :-)
print join("\t",ref(\[]),ref(\"foo"),ref(\*glob),ref(\do{my $x=*fo
+o}));
# REF SCALAR GLOB GLOB
Cheers,
--- demerphq
my friends call me, usually because I'm late....
|