--- Watch.pm (/vendor/Tie-Watch/Watch.pm) (revision 52314)
+++ Watch.pm (/local/Tie-Watch/lib/Tie/Watch.pm) (local)
@@ -239,6 +239,7 @@
use 5.004_57;;
use Carp;
+use Scalar::Util qw(reftype);
use strict;
use subs qw/normalize_callbacks/;
use vars qw/@array_callbacks @hash_callbacks @scalar_callbacks/;
@@ -263,7 +264,7 @@
my $variable = $args{-variable};
croak "Tie::Watch::new(): -variable is required." if not defined $variable;
- my($type, $watch_obj) = (ref $variable, undef);
+ my($type, $watch_obj) = (reftype $variable, undef);
if ($type =~ /(SCALAR|REF)/) {
@arg_defaults{@scalar_callbacks} = (
[\&Tie::Watch::Scalar::Destroy], [\&Tie::Watch::Scalar::Fetch],
--- /dev/null 2008-01-22 19:23:58.000000000 -0800
+++ t/object.t 2008-01-22 19:20:55.000000000 -0800
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -w
+
+use Test::More 'no_plan';
+
+use_ok 'Tie::Watch';
+
+{
+ package Bar;
+
+ sub method { 99 }
+}
+
+my %watcher;
+my $obj = bless { foo => 23 }, 'Bar';
+isa_ok $obj, 'Bar';
+
+my $watch = Tie::Watch->new(
+ -variable => $obj,
+ -store => sub {
+ my($self, $key, $val) = @_;
+ $watcher{$key} = $val;
+ $self->Store($key, $val);
+ },
+);
+
+is_deeply $obj, { foo => 23 };
+
+isa_ok $obj, 'Bar';
+$obj->{foo} = 42;
+is $obj->{foo}, 42;
+is $watcher{foo}, 42;
+
+is $obj->method, 99;
--- Makefile.PL (/vendor/Tie-Watch/Makefile.PL) (revision 52314)
+++ Makefile.PL (/local/Tie-Watch/Makefile.PL) (local)
@@ -3,7 +3,11 @@
WriteMakefile(
'NAME' => 'Tie::Watch',
'VERSION_FROM' => 'Watch.pm',
+ 'PREREQ_PM' => {
+ 'Test::More' => 0.47,
+ 'Scalar::Util' => 0,
+ },
($] >= 5.005 ?
(ABSTRACT => 'Place watchpoints on Perl (and Tk) variables',
AUTHOR => 'Steve Lidie (Stephen.O.Lidie@Lehigh.EDU)') : ()),