I have a situation where I'm trying to access class member data and TT
blows up with an 'undef error' because it was only able to try to
invoke the class method. Here is a patch under duress, probably not
perfect but fixes the problem for me.
Thanks,
--- Stash.pm~ Fri Mar 30 08:02:56 2001
+++ Stash.pm Tue Jun 5 21:11:24 2001
@@ -484,22 +484,28 @@
# UNIVERSAL object base class) then we call the item as a method.
# If that fails then we try to fallback on HASH behaviour if
# possible.
- eval { @result = $root->$item(@$args); };
+ eval { @result = $root->$item(@$args); };
if ($@) {
# failed to call object method, so try some fallbacks
- if (UNIVERSAL::isa($root, 'HASH')
- && defined($value = $root->{ $item })) {
- return $value unless ref $value eq 'CODE'; ## RETURN
- @result = &$value(@$args);
- }
- elsif (UNIVERSAL::isa($root, 'ARRAY')
- && ($value = $LIST_OPS->{ $item })) {
- @result = &$value($root, @$args);
- }
- else {
- @result = (undef, $@);
- }
+
+ # let's try and see if we are just breaking OO design
+ # by trying to access member data.
+ eval { @result = $root->{$item}; };
+ if ( $@ ) {
+ if (UNIVERSAL::isa($root, 'HASH')
+ && defined($value = $root->{ $item })) {
+ return $value unless ref $value eq 'CODE'; ## RETURN
+ @result = &$value(@$args);
+ }
+ elsif (UNIVERSAL::isa($root, 'ARRAY')
+ && ($value = $LIST_OPS->{ $item })) {
+ @result = &$value($root, @$args);
+ }
+ else {
+ @result = (undef, $@);
+ }
+ }
}
}
elsif (($value = $SCALAR_OPS->{ $item }) && ! $lvalue) {
Casey West
--
"If I had thought about it, I wouldn't have done the experiment. The
literature was full of examples that said you can't do this."
-- Spencer Silver on the work that led to the unique adhesives for
3-M "Post-It" Notepads.